上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: 1 #include<stdio.h> 2 int main() 3 { 4 int num, a; 5 for (num = 101; num <= 200; num += 2) //从101每次加1循环到200 6 { 7 for (a = 2; a < num; a++) //除数从2开始自加 阅读全文
posted @ 2020-03-13 19:34 新生代农民工 阅读(939) 评论(0) 推荐(0)
摘要: 素数即无法再被2到本身之间的数除尽 思路是 用循环从2到本身前一位数循环取模判断 1 #include<stdio.h> 2 int main() 3 { 4 int num, a, i; //a从2开始做除数给num取模 用一个变量来记录是否能被除尽 除尽一次则加一次 如果一次除不进则为素数 5 阅读全文
posted @ 2020-03-13 16:34 新生代农民工 阅读(572) 评论(0) 推荐(0)
摘要: 把前两位提前赋值输出,然后用循环把他们相加输出 每次都把相加的结果赋值给第二位加数,把第二位的加数赋值给第一位(务必把第二位赋值给第一位先执行否则就是算平方了) 循环相加输出 1 #include<stdio.h> 2 int main() 3 { 4 int a, b, c, d; 5 a = 1 阅读全文
posted @ 2020-03-13 16:10 新生代农民工 阅读(128) 评论(0) 推荐(0)
摘要: 输出4x5的矩阵 1 #include<stdio.h> 2 int main() 3 { 4 int j, k, n = 0; 5 for (j = 1; j <= 4; j++) .//打印列 只要打印换行即可 6 { 7 for (k = 1; k <= 5; k++, n++) //打印行 阅读全文
posted @ 2020-03-13 15:51 新生代农民工 阅读(117) 评论(0) 推荐(0)
摘要: 要求输出100-200的不能被3整除的数 #include<stdio.h>int main(){ int num; for (num = 100; num <= 200;num++) { if (num%3!=0) { printf("%d ", num); } } return 0;} 阅读全文
posted @ 2020-03-13 15:40 新生代农民工 阅读(160) 评论(0) 推荐(0)
摘要: 在全系1000学生中,征集慈善募捐,当总数达到10万元时就结束,统计此时捐款的人数,以及平均每人捐款的数目 #include<stdio.h>#define SUM 100000int main(){ float amount, aver, total; int i; for (i = 1, tot 阅读全文
posted @ 2020-03-13 15:36 新生代农民工 阅读(193) 评论(0) 推荐(0)
摘要: 企业发放的奖金根据利润提成。利润I低于或等于100 000元时,奖金可提10%;利润高于100,000元,低于200 000(100 000<I<=200 000)元时,低于100 000元的可按照10%提成,高于100 000元的部分,可提成7.5%;200 000<I<=400 000时,高于2 阅读全文
posted @ 2020-03-12 20:10 新生代农民工 阅读(573) 评论(0) 推荐(0)
摘要: 给一个不多于5位的正整数,要求:1.求它是几位数;2.逆序打印出各位数字;3.正序打印出各位数字。 #include<stdio.h>void counter(int x) //求数的有几位数{ int count = 0; while (x) { x /= 10; count++; //定义一个初 阅读全文
posted @ 2020-03-12 19:34 新生代农民工 阅读(193) 评论(0) 推荐(0)
摘要: 给出一个百分制成绩,要求输出成绩等级A,B,C,D,E。90分以上为A,80~89分为B,70~79分为C,60~69分为D,60分以下为E. #include<stdio.h>int main(){ float score; int code; scanf("%f",&score); if (sc 阅读全文
posted @ 2020-03-12 17:44 新生代农民工 阅读(271) 评论(0) 推荐(0)
摘要: 当y= -1 (x<0);y=0 (x=0);y=1(x<0),编一个程序,输入一个x值,输出y值 #include<stdio.h>int main(){ float x; int y; scanf("%f", &x); if (x < 0) y = -1; else if (x==0) y = 阅读全文
posted @ 2020-03-12 17:24 新生代农民工 阅读(167) 评论(0) 推荐(0)
上一页 1 ··· 3 4 5 6 7 8 9 下一页