Exchange output of data
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 128186 Accepted Submission (s): 47663
Problem description Enter the number of n (n<100) to find the smallest number, and then swap it with the first number to output these numbers.
Input data has multiple groups, one row per group, and the beginning of each line is an integer n, indicating the number of values for this test instance, followed by n integers. N=0 indicates the end of the input and does not handle it.
Output for each set of input data, outputs the swapped sequence, one row for each set of outputs.
Sample INPUT4 2 1 3 45 5 4 3 2 10
Sample OUTPUT1 2 3 41 4 3 2 5
1#include <cstdio>2#include <cstring>3 using namespacestd;4 inta[101];5 intMain ()6 {7 intN;8 while(SCANF ("%d", &n)!=eof&&N)9 {Ten intMin =0x3f3f3f; One intindex =-1; AMemset (A,0,sizeof(a)/sizeof(int)); - for(inti =0; I < n;++i) - { thescanf"%d",&a[i]); - if(Min >A[i]) - { -Min =A[i]; +index =i; - } + } A intt = a[0]; ata[0] =A[index]; -A[index] =T; - /* - a[0] = a[0] ^ A[index]; - A[index] = a[0] ^ A[index]; - a[0] = a[0] ^ A[index]; in */ - for(inti =0; I < n;++i) to { + if(i==n-1) - { theprintf"%d\n", A[i]); * Break; $ }Panax Notoginsengprintf"%d", A[i]); - } the } + return 0; A}
Exchange output of hdu2016 data "C + +"