View Code of Problem 83

#include<stdio.h>
struct student{
	int id;
	int socre;
}stu;
int main()
{
	int n,m,i,j;
	scanf("%d %d",&n,&m);
	stu a[n],b[m],c[n+m],t;
	for(i=0;i<n;i++)
	{
	  scanf("%d %d",&a[i].id,&a[i].socre);
	  c[i]=a[i];
    }  
	for(i=0;i<m;i++)
	{
	  scanf("%d %d",&b[i].id,&b[i].socre); 
	  c[i+n]=b[i];
   }
   for(i=0;i<m+n-1;i++)
   {
   	 int temp=i;
   	 for(j=i+1;j<m+n;j++)
   	 {
   	 	if(c[j].id<c[temp].id)
   	 	  temp=j;
	 }
	 t=c[temp];
	 c[temp]=c[i];
	 c[i]=t;
   }
   for(i=0;i<m+n;i++)
     printf("%d %d\n",c[i].id,c[i].socre);
	
}
/*
Main.c: In function 'main':
Main.c:10:2: warning: statement with no effect [-Wunused-value]
  stu a[n],b[m],c[n+m],t;
  ^
Main.c:10:6: error: expected ';' before 'a'
  stu a[n],b[m],c[n+m],t;
      ^
Main.c:13:19: error: 'a' undeclared (first use in this function)
    scanf("%d %d",&a[i].id,&a[i].socre);
                   ^
Main.c:13:19: note: each undeclared identifier is reported only once for each function it appears in
Main.c:14:4: error: 'c' undeclared (first use in this function)
    c[i]=a[i];
    ^
Main.c:18:19: error: 'b' undeclared (first use in this function)
    scanf("%d %d",&b[i].id,&b[i].socre); 
                   ^
Main.c:29:3: error: 't' undeclared (first use in this function)
   t=c[temp];
   ^
Main.c:23:10: warning: variable 'temp' set but not used [-Wunused-but-set-variable]
      int temp=i;
          ^
*/

Double click to view unformatted code.


Back to problem 83