www.5129.net > 输出1 100中的偶数

输出1 100中的偶数

#include<iostream.h> int main() { int i=1,sum=0; cout<<"1到100的所有偶数:"<<endl; do { if(i%2==0) { cout<<i<<endl; sum+=i; } i++; }while(i<=100); cout<<"1到100所有偶数和是:"<<sum; return 0; } 没有VC++,没办法调试运行,你运行试下看看有没有小错误.

#include <stdio.h> int main() { for (int i = 2; i <= 100; i += 2) { printf("%d ", i); } }

#include<stdio.h> void mian() { int i; for(i=0;i<=100;i++) { if(i%2==0) printf("%d\n",i); } }

int i ; for(i=1;i<=100;i++) { if(i%2==0) printf(i); if(i%20==0) printf("\n"); }

#include<stdio.h> void main() { int a,b=0; for(a=1;a<=100;a++) { if(!(a%2)) { printf("%d\t",a);//输出所有偶数 b++; } if(!(b%5)&&b!=0) printf("\n"); } }

var a,b,c,i:integer;begin a=0; for i:1 to 100 do if i mod 2=0 then a=a+1; writeln(a); end.

#include <stdio.h>main(){ double p=1.0,i; for(i=2;i<=100;i+=2) p *= i; printf("product is %lf\n",p);}必须用double类型,不然会溢出.

#include<stdio.h> int main(){ int x, n=0; for(x=2; x<=100; x+=2){ printf("%4d", x); n++; if(n==19){ printf("\r\n"); n=0; } } printf("\r\n"); }

int j=0; for(int i=1;i<=100;i++){ if(j==5){ System.out.println(""); j=0; } if(i%2==0){ System.out.print(i); j++; } }

#include main() { int i; for(i=1;i

友情链接:9371.net | lyxs.net | rprt.net | mcrm.net | pznk.net | 网站地图

All rights reserved Powered by www.5129.net

copyright ©right 2010-2021。
www.5129.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com