int j; for (j = 2; j <= 10; j++) { printf("%d位数为奇数的个数%ld\n", j-1, s); if (j <= 2) s *= 9; else s *= 10; sum += s; } printf("%d位数为奇数的个数%ld\n", j-1, s); printf("奇数的总个数为:%ld\n", sum); return 0; } 结果截图:加油...
include <stdio.h>int main(){ int a,i; scanf("%d",&a); for(i = 1; i <=a; i += 2) { printf("%d ", i); if(i/2%5==4)printf("\n"); } return 0;}代码供参考
main(){ int i=1,sum=0;for(;i<=100;){ s=s+i;i=i+2;} printf("sum=%d",sum);}
第1题 include <stdio.h>int main(){ int i, j = 0; for (i = 0; i <= 100; ++i){ if (i % 2 == 1){ j++; printf ("%d ", i); if (j == 5){ printf ("\n"); j = 0; } } } return 0;}第二题 include <stdio.h>in...
题目1 include <stdio.h>int main(){ int i; int cnt=0; for(i=1;i<100;i+=2) { printf("%2d ",i); cnt++; if(cnt%5==0) { printf("\n"); } } return 0;}题目2 include <stdio.h>int main(){ int i; int sum=0; fo...
编写一个C程序,求0-100之间的奇数之和 5.编写一个C程序,求-100之间的奇数之和。 #include<stdio.h>main(){ int n,sum=0; for(n=1;n<=100;n++) { if(1==n%2) sum+=n; } printf("Sum is %d\n",sum);}
include<stdio.h> define M 20 int main(void){ int i,a[M],j=0;for(i=0;i<M;i++)scanf("%d",a+i);for(i=0;i<M;i++)if(a[i]%2!=0){ int t;t=a[j];a[j]=a[i];a[i]=t;j++;} for(i=0;i<M;i++)printf("%2d",a[i]);printf("\n");return 0;} ...
//用c语言写一个0到99的数,分为奇数和偶数两组。并保存到两个数组中,将两个数组的元素都输出到屏幕。#include "stdio.h"int main(int argc, char* argv[]){int nlEven[50] = {0};//偶数数组int nlOdd[50] = {0};//奇数数组int nSignEven = 0;//偶数数组的下标int nSignOdd =...
在整数0到20中,奇数有哪些?,偶数有哪些?质数有哪些?合数有哪些? 扫码下载作业帮搜索答疑一搜即得 答案解析 查看更多优质解析 解答一 举报 基数,1,3,5,7,9,11,13,15,17,1;偶数:2,4,6,8,10,12,14,16,18,20 解析看不懂?免费查看同类题视频解析查看解答 ...
你把n跟0x01相与,看结果是不是为0。为0是偶数,不为0是奇数,就这么简单。int odd(int n){ return n&0x01;}