View Code of Problem 49

#include<stdio.h>
void main()    
{
      int n,i[11],max,min,t,maxt=0,mint=0;
      scanf("%d\n",&n);
      for(t=0;t<=n-1;t++)
         scanf("%d",&i[t]);
         max=min=i[0];
         for(t=0;t<=n-1;t++)
	  {
      if(i[t]>max)
	  {max=i[t];maxt=t;}
      if(i[t]<min)
	  {min=i[t];mint=t;}
	  }
      t=i[maxt];i[maxt]=i[n-1];i[n-1]=t;
      t=i[mint];i[mint]=i[0];i[0]=t;
      for(t=0;t<=n-2;t++)
	  {
     		if (i < n-1)
		printf("%d ", a[i]);
		else 
		printf("%d\n", a[i]);
	  }
}

/*
Main.c:2:6: warning: return type of 'main' is not 'int' [-Wmain]
 void main()    
      ^
Main.c: In function 'main':
Main.c:20:14: warning: comparison between pointer and integer
        if (i < n-1)
              ^
Main.c:21:17: error: 'a' undeclared (first use in this function)
   printf("%d ", a[i]);
                 ^
Main.c:21:17: note: each undeclared identifier is reported only once for each function it appears in
*/

Double click to view unformatted code.


Back to problem 49