帮我看看
c吧
全部回复
仅看楼主
level 1
熊猫在世 楼主
我想做一个找最大值的程序,可总是不对,求教。谢谢!#include
#include
int main(void){ int a[20],b1,b2,c,d,e,f,g,max,maxc; c=0; while(scanf("%d",&a[c])==1) { c++; } c=c-1; for (d=0;d<=c;d++) { f=c; for (e=0;e<=f;e++) { if (a[d]>a[d+1]) { max=a[d]; maxc=d; } else { max=a[d+1]; maxc=d+1; } } for (g=maxc;g<(f-maxc);g++) { a[g]=a[g+1]; } printf("%d ",max); f--; } system("pause");}
2008年12月11日 09点12分 1
level 0
小白路过帮顶
2008年12月11日 10点12分 2
level 1
熊猫在世 楼主
还是不行……#include
#include
int main(void){ int a[20],c,d,e,f,g,max,maxc; c=0; while(scanf("%d",&a[c])==1) { c++; } c=c-1; for (d=0;d<=c;d++) { f=c; for (e=0;e<=f;e++) { if (a[e]>a[e+1]) { max=a[e]; maxc=e; } else { max=a[e+1]; maxc=e+1; } } for (g=maxc;g<(f-maxc);g++) { a[g]=a[g+1]; } printf("%d ",max); f--; } system("pause");}
2008年12月11日 10点12分 3
level 1
d`````
2008年12月11日 12点12分 4
level 1
熊猫在世 楼主
搞定。#include
#include
int main(void){ int a[20],b,c,d,e,qz; b=1; while (scanf("%d",&a[b])==1) { b++; } b=b-1; for (d=2;d<=b;d++) { qz=a[d]; e=d-1; while (e>0 && a[e]>qz) { a[e+1]=a[e]; e--; } a[e+1]=qz; } for (e=1;e<=b;e++) { printf("%d ",a[e]); } printf("\n"); system("pause"); return 0;}
2008年12月13日 08点12分 5
level 1
熊猫在世 楼主
up
2008年12月15日 08点12分 6
level 1
是C语言?看起来和C++挺像的说。
2009年01月07日 13点01分 7
1