??????1??e??????????????
??????????????n?????????н??????????У?e???????????????
????????????е??????е????????????????????????ζ????????????б????????????С????????????λ???
???????????????????????????????????????????????????????????????????????ζ????????????б????????????С????????????λ???
??????????????n-1?????????????????Σ????????????
??????1?????????10??????????????e????????????к??????
????#define n 10
????main()
????{
????int a[n]??i??j??t;
????for(i=0;i<n;i++)
????scanf("%d"??&a[i]);
????for(j=1;j<=n-1;j++) /*n????????n-1??*/
????for(i=0;i<=n-1-j;i++) /*???????????????*/
????if(a[i]>a[i+1])
????{t=a[i];a[i]=a[i+1];a[i+1]=t;}
????for(i=0;i<n;i++)
????printf("%d "??a[i]);
????}
??????2?????????
???????????????????????????????????????n?????????н??????????У??????????
??????????????n?????????С?????±??????????“???”???????С?????1????????λ???
?????????1???????????????n-1?????????С??????n?????е??С???????±??????????2????????λ???
??????????????n-1??????????????
??????1?????????10??????????????????????????к??????
????#define n 10
????main()
????{
????int a[n]??i??j??k??t;
????for(i=0;i<n;i++)
????scanf("%d"??&a[i]);
????for(i=0;i<n-1;i++)/*????n-1??*/
????{
????k = i; /*??????????????????????????????i??????С??k??????±?*/
????for(j=i+1;j<n;j++)
????if(a[j] < a[k]) k = j;
????if (k != i)
????{t = a[i]; a[i] =a[k]; a[k] = t;}
????}
????for(i=0;i<n;i++)
????printf("%d "??a[i]);
????}
??????3?????????? ??????????????????????“???????е??????”???????????????????????к?????????????????????μ??????“???????????”??
??????1????????????????x????????????к???????????????С?
????#definen10
????main()
????{
????inta[n]={-1??3??6??9??13??22??27??32??49}??x??j??k;/*??????????????????*/
????scanf("%d"??&x);
????if(x>a[n-2])
????a[n-1]=x/*???????????????????????д??*/
????else/*???????λ??*/
????{
????j=0;
????while(j<=n-2&&x>a[j])
????j++; /*??????????????????λ??????????κ????λ*/
????for(k=n-2;k>=j;k--)
????a[k+1]=a[k];
????a[j]=x;/*?????????*/}
????for(j=0;j<=n-1;j++)
????printf("%d"??a[j]);}
??????????????????????????????????????????????У???β???????????????
??????2?????????10?????????????ò????????????к??????
????#definen10
????main()
????{
????inta[n]??i??j??k??x;
????scanf("%d"??&a[0]);/*???????????????浽a[0]??*/
????for(j=1;j<n;j++)/*????2????10?????????????????a??*/
????{
????scanf("%d"??&x);
????if(x<a[j-1])a[j]=x;/*??????к????????С??????????????????????*/
????else/*???2??????λ??*/
????{
????i=0;
????while(x<a[i]&&i<=j-1)i++; /*????for???????????????????????λ??????????κ????λ*/
????for(k=j-1;k>=i;k--)
????a[k+1]=a[k];
????a[i]=x;/*?????????*/
????}
????}
????for(i=0;i<n;i++)
????printf("%d "??a[i]);
????}
??????4???鰱????
?????????????????????????е????????к????????????????е????С?
??????1???????????6??????????????к????????4??????????????У??????????????????10??????????????С?
????#define m 6 #define n 4
????main()
????{
????int a[m]={-3??6??19??26??68??100} ??b[n]={8??10??12??22};
????int i??j??k??c[m+n];
????i=j=k=0;
????while(i<m && j<n)/*??a??b?????е??С?????δ???c??????*/
????{
????if(a[i]<b[j]){c[k]=a[i]; i++;}
????else {c[k]=b[j]; j++;}
????k++;
????}
????while(i>=m &&j<n) /*??a??????????????????b?????μ??????????c??*/
????{c[k]=b[j]; k++; j++;}
????while(j>=n &&i<m) /*??b??????????????????a?????μ??????????c??*/
????{c[k]=a[i]; k++; i++;}
????for(i=0;i<m+n;i++)
????printf("%d "??c[i]);
????}
????(5)??????
??????????????????????????????????????????????????????????????????????????????????????????
???????磬????????????????????????????????????????????????????????????????????????μ???????????????????????????????????????μ????
???????????????10???????????????????????????????????????????
????main()
????{
????int day??peach;
????peach=1;
????for(day=9;day>=1;day--)
????peach=(peach+1)*2;
????printf("The first day:%d "??peach);
????}
????(6)???????
??????1??????????????????????? ??????????????m?????r?????????·?????m???????r?????????????0???????????????????м?????????
?????????????????????????????????????????????
???????磬?????????????????????????????????????????????????????
????void tran(int m??int r??char str[]??int *n)
????{
????char sb[]="0123456789ABCDEF";
????int i=0??g; do{g=m%r;
????str[i]=sb[g];
????m=m/r;
????i++;
????}
????while(m!=0);
????*n=i;
????}
????main()
????{
????int x??r0; /*r0????????*/
????int i??n; /*n?д?????????е???????*/
????char a[50];
????scanf("%d%d"??&x??&r0);
????if(x>0&&r0>=2&&r0<=16)
????{
????tran(x??r0??a??&n);
????for(i=n-1;i>=0;i--)
????printf("%c"??a[i]);
????printf(" ");
????}
????else exit(0);
????}
??????2??????????????????????? ?????????????????????????????????“??????”?????磬?ж???????101011???????????????1×25+0×24+1×23+0×22+1×21+1×20=43????r
??????????an……a2a1??nλ????????????????????????an×r n-1+……a2×r1+a1×r0??
??????????????????????????????????