Exchange output of hdu2016 data "C + +"

Source: Internet
Author: User

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 + +"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.