随笔分类 -  c语言

上一页 1 2 3 4 5 6 7 8 9 10 ··· 29 下一页
摘要:#include <stdio.h> //输出1980-2020年之间所有的闰年,每行三个 main() { int year,【1】,b; for(year=1980;year<=2020;year++) { 【2】; if(【3】) { printf("%5d",year); count++; 阅读全文
posted @ 2023-02-17 10:08 myrj 阅读(648) 评论(0) 推荐(0)
摘要:#include <stdio.h> //用来统计输入的字符中所有大写字母的个数,用#结束输入 main() { int a[26],i; char ch; for(i=0;i<26;i++) a[i]=【1】; ch=getchar(); while(【2】) { if(ch>=65&&ch<=9 阅读全文
posted @ 2023-02-17 09:48 myrj 阅读(534) 评论(0) 推荐(0)
摘要:#include <stdio.h> //功能:从键盘输入一个整数,如果不高于9999则逆序输出,否则打印“输入范围错误" main() { 【1】; 【2】; if(x<=9999) do{ printf("%d",【3】); 【4】; }【5】 else printf("输入范围错误"); ge 阅读全文
posted @ 2023-02-17 09:34 myrj 阅读(106) 评论(0) 推荐(0)
摘要:#include <stdio.h> //功能:从键盘上输入若干学生的成绩,统计并输出最高成绩和最低成绩 //当输入负数时结束输入,请将程序补充完整 main() { float x,amax,amin; scanf("%f",【1】) ; amax=x; amin=x; while(【2】) { 阅读全文
posted @ 2023-02-17 09:27 myrj 阅读(321) 评论(0) 推荐(0)
摘要:#include <stdio.h> //求s=1-3+5-7+...-99+101并输出 main() { int i,t=1,【1】; for(i=1;【2】;【3】) { s=【4】; t=【5】; } printf("s=%d\n",s); getchar(); } 求s=1-3+5-7+. 阅读全文
posted @ 2023-02-17 09:18 myrj 阅读(605) 评论(0) 推荐(0)
摘要:#include <stdio.h> //求s=3+13+23+...+103 main() { int 【1】; for(i=0;【2】;i++) s=【2】; printf("s=【4】\n",s); getchar(); } #include <stdio.h> //求s=3+13+23+.. 阅读全文
posted @ 2023-02-17 09:07 myrj 阅读(270) 评论(0) 推荐(0)
摘要:#include <stdio.h> //找出二维数组中的最大值,并输出所有最大值对应的行与列 main() { int a[5][5]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,24,24,15,16,21,17,18,19,24,22,23} ,max,hang,lie, 阅读全文
posted @ 2023-02-16 19:56 myrj 阅读(362) 评论(0) 推荐(0)
摘要:#include <stdio.h> //求二维数组中的最大值及对应的行号与列号 main() { int a[5][5]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,24,15,16,21,17,18,19,20,22,23} ,max,hang,lie,c,b; ma 阅读全文
posted @ 2023-02-16 19:52 myrj 阅读(1134) 评论(0) 推荐(0)
摘要:#include <stdio.h> //变量作用域:局部变量 全局变量 //函数外声明的变量称为全局变量,函数内声明的变量的称为局部变量 //变量生存周期:变量的存在时间 //静态存储方式:指在程序运行期间分配固定的存储空间 //动态存储方式:指在程序运行期间根据需要动态分配存储空间 //c语言程 阅读全文
posted @ 2023-02-15 14:44 myrj 阅读(222) 评论(0) 推荐(0)
摘要:#include <stdio.h> //利用指针排序 main() { int a[6]={6,5,4,3,2,1},i,j,k; int *p[6],*t; for(i=0;i<6;i++) p[i]=&a[i]; for(i=0;i<6;i++) { k=i; for(j=i+1;j<6;j+ 阅读全文
posted @ 2023-02-15 11:27 myrj 阅读(183) 评论(0) 推荐(0)
摘要:#include <stdio.h> //假期小王跟随父亲去钓鱼,小王的父亲在这期间钓到了一条大鱼距离岸边 l 米,小明的父亲每5分钟向岸边收m米,然后休息 2分钟,这时鱼会向外游出n米, //试编写一个函数:对于任意指定的l,m,n值,试问小王父亲多少分钟可以把这条鱼钓上岸。 float sja( 阅读全文
posted @ 2023-02-15 11:22 myrj 阅读(82) 评论(0) 推荐(0)
摘要:#include <stdio.h> //数组a中有8个不相等的元素,b中有5个不相等的元素,数组c中包含那些a中但不在b中的元素,并输出数组c各元素的值 main() { int a[8],b[5],i,j,count; 【1】 for(i=0;i<8;i++) 【2】 for(i=0;i<5;i 阅读全文
posted @ 2023-02-14 11:33 myrj 阅读(105) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <math.h> main() { float s=1,pi=0,i=1.0,n=1.0; while(fabs(i)>=1e-6) { pi+=i; n=n+2; s=-s; i=s/n; } pi=4*pi; printf("pi的值是:% 阅读全文
posted @ 2023-02-13 11:32 myrj 阅读(242) 评论(0) 推荐(0)
摘要:#include<stdio.h> main() { int shu[10]={0},su,max[2]; while((su=getchar())!='\n') shu[su-48]++; for(su=1,max[1]=0;su<10;su++) if(shu[su]>=max[1]) max[ 阅读全文
posted @ 2023-02-13 11:16 myrj 阅读(1224) 评论(0) 推荐(0)
摘要:#include <stdio.h> main() { int n,a,b=0,c; scanf("%d",&n); printf("%d=1*",n); for(a=2;a<n;a++) {c=0; if(n%a==0) printf("%d",a),b++,c=1; if(b%2==1&& c= 阅读全文
posted @ 2023-02-13 07:19 myrj 阅读(87) 评论(0) 推荐(0)
摘要:#include <stdio.h> main() { int n; while(~scanf("%d",&n)) { printf("%d\n",n); if(n==0) break; } getchar(); } 阅读全文
posted @ 2023-02-13 06:07 myrj 阅读(23) 评论(0) 推荐(0)
摘要:#include<stdio.h> int main() { int m,i,count=0;//定义一个正整数m,因子i,因子计数count,刚开始因子为0; printf("请输入一个正整数:\n"); scanf("%d",&m); for(i=1;i<=m;i++)//用for循环来从1因子 阅读全文
posted @ 2023-02-13 06:00 myrj 阅读(201) 评论(0) 推荐(0)
摘要://求最小公倍数 //两个或多个整数公有的倍数叫做它们的公倍数,其中除0以外最小的一个公倍数就叫做这几个整数的最小公倍数。 #include <stdio.h> main() { int m,n,i,k,max,min; scanf("%d,%d",&m,&n); max=m>n?m:n; min= 阅读全文
posted @ 2023-02-13 05:55 myrj 阅读(298) 评论(0) 推荐(0)
摘要:#include <stdio.h> //两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。 //已抽签决定比赛名单,有人向队员打听比赛的名单。a说他不和x比, //c说他不和x、z比,请完成程序填空,实现找出三队赛手的名单。 main() { char i,j,k;//i 阅读全文
posted @ 2023-02-12 17:07 myrj 阅读(80) 评论(0) 推荐(0)
摘要:#include <stdio.h> //求s=1+1/3+1/5+....之和,直到某一项的值小于10的-6次方时停止累加 main() { float a=1,【1】,b,c; while(【2】) { s=s+【3】; a=【4】; } printf("%f\n",s); getchar(); 阅读全文
posted @ 2023-02-12 16:50 myrj 阅读(116) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 9 10 ··· 29 下一页