View Code of Problem 22

#include <stdio.h>
#include <string.h>
int main()
{
	char str1[1000],str2[1000];
	int l1,l2,i,j;
	int k[26];
	while(scanf("%s",str1)!=EOF && scanf("%s",str2)!=EOF)
	{
		l1=strlen(str1);
		l2=strlen(str2);
		k[26]={0};
		for(i=0;i<l1;i++)
		{
			for(j=0;j<l2;j++)
			{
				if(str1[i]==str2[j])
				{
					k[str1[i]-'a']++;
					str2[j]='0';
					break;
				}
			}
		}
		for(i=0;i<26;i++)
		{
			for(j=k[i];j>0;j--)
			{
				printf("%c",i+'a');
			}
		}
		printf("\n");
	}
	return 0;
}
/*
Main.c: In function 'main':
Main.c:12:9: error: expected expression before '{' token
   k[26]={0};
         ^
*/

Double click to view unformatted code.


Back to problem 22