Tag: amp UTC While line pre main har C + + =
1 //Simplified bucket sequencing, time complexity O (m+n)->o (m+n)2 //problem: Randomly enter a few groups of numbers and sort them automatically (from small to large or from large to small)3#include <bits/stdc++.h>4 using namespacestd;5InlineintRead ()6 {7 intx=0, f=1;8 CharCh=GetChar ();9 while(ch<'0'|| Ch>'9')Ten { One if(ch=='-') Af=-1; -Ch=GetChar (); - } the while(ch>='0'&&ch<='9') - { -x=x*Ten+ch-'0'; -Ch=GetChar (); + } - returnx*F; + } AInlinevoidWriteintx) at { - if(x<0) - { -Putchar ('-'); -x=-x; - } in if(x>9) - { toWrite (x/Ten); + } -Putchar (%Ten+'0'); the } * inta[ One];//stores the number of occurrences of a number in a 1~10 $ Panax Notoginseng - intMain () the { + for(intI=1; i<=Ten; i++) A { the intx; +Cin>>x; -a[x]++; $ } $ //sort from small to large - /* - for (int i=1;i<=10;i++) the { - for (int j=1;j<=a[i];j++)//print 1~10 number of occurrences of a number of times, print several timesWuyi { the cout<<i<< ""; - } Wu } - */ About //sort from big to small $ for(intI=Ten; i>=1; i--) - { - for(intj=1; j<=a[i];j++) - { Acout<<i<<" "; + } the } - return 0; $}
Simplified bucket sequencing Operation template