
自从那次校赛没过以后就一直没心思做题,现在连水题要注意的PE也交了6次再看了一份AC代码才想起来,多输出了空格再换行也是会PE的。 真的是代码打得太少了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <cstdio> #include <cstring> #include <cstdlib>
void swap(char *s,int j){ char temp = s[j]; s[j] = s[j+1]; s[j+1] = temp; }
void Bubblesort(char *s){ char temp = s[0]; for(int i = 0;i < 3;i++){ for(int j = 0;j < 2;j++){ if(s[j] > s[j+1]) swap(s,j); } } }
int main(){ //freopen("in.txt","r",stdin); char s[4]; while(scanf("%s",s)!=EOF){ //getchar(); Bubblesort(s); for(int i = 0;i < 2;i++){ printf("%c",s[i]); printf(" "); } printf("%c",s[2]); printf("n"); } //printf("n"); return 0; }
|
近期评论