void main() {
int a=2,b=5,c=0;
if(a+b>10) c=a*b; else c=3*a+b;
if(c<=20) cout< a=a+b; b=a+b;c+=a+b; cout<<\ } 5. #include int x=5; switch(2*x-3) { case 4: cout< case 10: cout<<3*x-1<<’ ’; break; default: cout<<\ } cout<<\ } 6. #include int a[4]={36,-5,73,8}; void main() { int i,y; for(i=0; i<4; i++) { if(a[i]<0) y=1; else if(a[i]<10) y= a[i]* a[i]+3; else if(a[i]<60) y=4*a[i]-5; else y=int(sqrt(a[i])); // sqrt(x)为取x的平方根函数 cout< 7. #include int a[8]={36,25,20,43,12,70,66,35}; void main() { int s0,s1,s2; s0=s1=s2=0; for(int i=0; i<8; i++) { switch(a[i]%3) { case 0: s0+=a[i];break; case 1: s1+=a[i];break; case 2: s2+=a[i];break; } } cout< 8. #include int i,p=1,s=0; for(i=1;i cout< 9. #include int c2,c3,c5; c2=c3=c5=0; for(int i=1; i<=M; i++) { if(i%2==0) c2++; if(i%3==0) c3++; if(i%5==0) c5++; } cout< 10. #include int i,j; for(i=0;i<5;i++) { for(j=i;j<5;j++) cout<<’*’; cout< 11. #include for(int i=1,s=0;i<20;i++) { if(i%2==0 || i%3==0) continue; cout< cout< 12. #include int i,j; for(i=1;i<=T;i+=2) for(j=2;j<=T;j+=2) { if(i+j 13. #include int a,b,c=0; for(a=1;a<4;a++) for(b=6;b>1;b-=2) { if((a+b)%2==0) c+=a+b; else c+=a*b; if(b==2) cout< 14. #include int p=1,s=1; while(s<50) { p*=B; s+=p; } cout<<\ } 15. #include int x=24,y=88; int i=2,p=1; do { while(x%i==0 && y%i==0) { p*=i; x/=i; y/=i; } i++; }while(x>=i && y>=i); cout< 16. #include int a[N][N]={{7,-5,3},{2,8,-6},{1,-4,-2}}; int b[N][N]={{3,6,-9},{2,-8,3},{5,-2,-7}}; int i,j,c[N][N]; for(i=0;i c[i][j]=a[i][j]+b[i][j]; for(i=0;i cout< 17. #include void main() { int b=a+20; int a=10; cout< for(int i=1; i<6; i++) { a+=i; b+=a; } cout<