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

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

#include int main() { void eve(int); int a; printf("please input a number"); scanf("%d",&a); eve(a);//你的调用格式不对!你的调用格式不对!你的调用格式不对! return 0; } void eve(int n) { if(n%2==0) printf("the eve is even"); el...

#includeint even(int num) { return num%2; }int main() { int sum=0,num=0; printf("Input integers:"); while (1) { scanf("%d",&num); if (num

#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;}

定义一个数用来进行累加然后进行循环即可循环中对输入的数求余2确定其是否为奇数如果是则累加如果输入的数为0或者负数退出循环最后再输出值就完成了如果代码不想自己写的话我可以有偿代劳

#include int even(int num) { return num%2; } int main() { int sum=0,num=0; printf("Input integers:"); while (1) { scanf("%d",&num); if (num

#includeint main(){ int num,sum=0; while(scanf("%d",&num)&&num>0) { if(num%2==0) sum+=num; } printf("偶数和为:%d\n",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 #define NUM 100 int main() { int data[NUM],i,sum=0; printf("请输入一组正整数,以负数或者0结尾"); for(i=0;i

#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;}

#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

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