jcst.net
当前位置:首页 >> 编程C语言输入一批正整数以0或负数为结束标志求奇... >>

编程C语言输入一批正整数以0或负数为结束标志求奇...

已在TC2下经过测试,如果觉得好,请采纳。。。 #include #include int Even(int * array, int num); /*定义*/ void main() { int ii, MyArray[100] = {0}; clrscr(); printf("Pls input numbers, to end this input operation, pls put a number

#include int main() { int n,sum=0; printf("请输入一列整数:"); scanf("%d",&n); while(n>0) { if(n%2==0) sum=sum+n; scanf("%d",&n); } printf("这列整数中偶数和为:%d\n",sum); return 0; }

希望能帮到你!以下是程序:#include #include int iseven(int x) { if(x%2==0) return 1; else return 0; }int main() { int i,x,sumofodd=0; printf("Input integers: "); while(scanf("%d",&x)!=EOF) { if(x

#include int main(){ int num; int sum=0; scanf("%d",&num); while(num>0) { if(num%2==0) { num=0; } sum+=num; scanf("%d",&num); } printf("%d",sum); return 0;}

#include int main(void){int i,n=0,hj=0,sz[100];printf(" 请输入第 %d 个正整数(0结束输入):",n+1);while(scanf("%d",&sz[n])==1 && sz[n] != 0){n++;printf(" 请输入第 %d 个正整数(0结束输入):",n+1);}for(i=0;i

#include int main(int argc, char *argv[]){ int a, num; a = num = 0; scanf("%d", &a); while(a > 0) { if (a % 2 == 1) { num += a; } scanf("%d", &a); } printf("奇数和: %d\n", num); return 0;}

#include #include "limits.h"int main(void){ int n,min=INT_MAX; while(scanf("%d",&n),n>=0) if(min>n) min=n; printf("The MIN is %d\n",min); return 0;}

#include #define NUM 100 int main() { int data[NUM],i,sum=0; printf("请输入一组正整数,以负数或者0结尾"); for(i=0;i

#includeint perime( int n){int i;if(n == 1) return 0;for(i =2;i*in) return 1;else return 0;}int main(){int n,sum = 0;while(scanf("%d",&n) == 1) {if(n

#includeint main(void){ int number,a; scanf("%d",&a); if(a%2==0) printf("偶数!"); else printf("奇数!"); if(a==0){ printf("\n0既不是整数也不是负数"); goto ab;} if(a

网站首页 | 网站地图
All rights reserved Powered by www.jcst.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com