View Code of Problem 22

// 111.cpp : 定义控制台应用程序的入口点。
//

#include<stdio.h>
#include<string.h>
int main()
{
	char a[1001]={0},b[1001]={0};
	int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
	while(scanf(gets(a)&&gets(b)!=EOF)
	{
		Lenth1=strlen(a);
		Lenth2=strlen(b);
 		for(i=0;i<Lenth1;i++)
			x[a[i]]++;
		for(i=0;i<Lenth2;i++)
			y[b[i]]++;
		for(i='a';i<='z';i++)
		{
			if(x[i]<y[i])
				z[i]=x[i];
			else
				z[i]=y[i];
			for(j=0;j<z[i];j++)
				printf("%c",i);
		}
		for(i='a';i<='z';i++)
			x[i]=y[i]=0;
		printf("\n");
	}
	return 0;
}

/*
Main.c: In function ‘main’:
Main.c:10:2: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
  while(scanf(gets(a)&&gets(b)!=EOF)
  ^
Main.c:10:2: warning: ‘gets’ is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
Main.c:10:30: warning: comparison between pointer and integer [enabled by default]
  while(scanf(gets(a)&&gets(b)!=EOF)
                              ^
Main.c:10:2: warning: passing argument 1 of ‘scanf’ makes pointer from integer without a cast [enabled by default]
  while(scanf(gets(a)&&gets(b)!=EOF)
  ^
In file included from /usr/include/features.h:374:0,
                 from /usr/include/stdio.h:27,
                 from Main.c:4:
/usr/include/stdio.h:446:12: note: expected ‘const char * restrict’ but argument is of type ‘int’
 extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
            ^
Main.c:10:2: warning: format not a string literal and no format arguments [-Wformat-security]
  while(scanf(gets(a)&&gets(b)!=EOF)
  ^
Main.c:11:2: error: expected ‘)’ before ‘{’ token
  {
  ^
Main.c:32:1: error: expected expression before ‘}’ token
 }
 ^
Main.c:9:51: warning: unused variable ‘Lenth2’ [-Wunused-variable]
  int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
                                                   ^
Main.c:9:44: warning: unused variable ‘Lenth1’ [-Wunused-variable]
  int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
                                            ^
Main.c:9:42: warning: unused variable ‘k’ [-Wunused-variable]
  int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
                                          ^
Main.c:9:40: warning: unused variable ‘j’ [-Wunused-variable]
  int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
                                        ^
Main.c:9:38: warning: unused variable ‘i’ [-Wunused-variable]
  int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
                                      ^
Main.c:9:28: warning: unused variable ‘z’ [-Wunused-variable]
  int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
                            ^
Main.c:9:17: warning: unused variable ‘y’ [-Wunused-variable]
  int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
                 ^
Main.c:9:6: warning: unused variable ‘x’ [-Wunused-variable]
  int x[200]={0},y[200]={0},z[26]={0},i,j,k,Lenth1,Lenth2;
      ^
*/

Double click to view unformatted code.


Back to problem 22