1 solutions

  • 0
    @ 2025-3-3 16:33:48

    C :

    #include<stdio.h>
    #include<string.h>
    main()
    {
    	char a[100],b[100];
    	int c[150]={0};
    	int i;
    	gets(a);
    	gets(b);
    	strcat(a,b);
        for(i=0;i<strlen(a);i++)
        {
        	int k=a[i];
        	if(c[k]==0)
        	{
        		printf("%c",a[i]);
        		c[k]++;
    		}
    	}
    }
    

    C++ :

    #include<iostream>      
    #include<string>
    using namespace std;  
    int main(){           
       string s1,s2;
       int a[26];
       cin>>s1;
       cin>>s2;
       s1 = s1 + s2;
       for(int i = 0;i <= 25;i++)  
       {
       	  a[i] = 0;
       }
       for(int i = 0;i < s1.length();i++)
       {
       	  if(a[s1[i] - 97] == 0){
       	     cout<<s1[i];	
       	     a[s1[i] - 97] = 1;
    	  }
       }
       cout<<endl;
    } 
    
    

    Python :

    a = input()
    b = input()
    c = a + b
    li=[]
    for i in range (0,25):
        li.append(0)
    for i in c:
        li[ord(i)-97] += 1 
        if li[ord(i)-97] == 1:
            print(i,end='')
        
    
    • 1

    Information

    ID
    10711
    Time
    1000ms
    Memory
    32MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By