Untitled

From Reliable Parrot, 1 Year ago, written in Plain Text, viewed 333 times.
URL http://codebin.org/view/7244b351 Embed
Download Paste or View Raw
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <stdlib.h>
  5.  
  6. int main() {
  7.  
  8.     /* Enter your code here. Read input from STDIN. Print output to STDOUT */
  9.     int tc,n;
  10.     scanf("%d\n",&tc);
  11.     while(tc--)
  12.     {
  13.         scanf("%d\n",&n);
  14.         int a[n];
  15.         for(int i =1;i<=n;i++)
  16.         {
  17.             scanf("%d ",&a[i]);
  18.         }
  19.         for(int i =1;i<=n;i++)
  20.         {
  21.             for(int j =i+1;j<=n;j++)
  22.             {
  23.                 if(a[j]<a[i])
  24.                 {
  25.                     int temp =a[j];
  26.                     a[j]=a[i];
  27.                     a[i]=temp;
  28.                 }
  29.             }
  30.         }
  31.         for(int i=1;i<=n;i++)
  32.         {
  33.             //printf("%d ",a[i]);
  34.             if(a[i]!=i)
  35.             {
  36.                 printf("%d\n",i);
  37.                 break;
  38.             }
  39.         }
  40.     }
  41.    
  42.    
  43.     return 0;
  44. }
  45.  
  46.  

Reply to "Untitled"

Here you can reply to the paste above