08 2019 档案

摘要:#include /*题目:利用冒泡法对10个数进行排序*/ int main(){ int i,j,k,t; int a[10]; while(1){ printf("——冒泡法排序——\n"); for(i=0;i<10;i++){ printf("请输入第%d个排序数字",i+1); scanf("%d",&a[i]); } for(j=0;j<9;j++) for(k=j+1;k... 阅读全文
posted @ 2019-08-31 10:37 狗狗王 阅读(3247) 评论(1) 推荐(0)
摘要:#include /*题目:求100以内素数*/ int main(){ int i,j,k,m,n; lop: while(1){ printf("——列出m-n之间素数——\n请输入起始数:"); scanf("%d",&m); if(m<=1){ printf("输入错误,请重新输入"); goto lop;} printf("请输入终止数:"); scanf("%d",&n); for(... 阅读全文
posted @ 2019-08-30 21:53 狗狗王 阅读(2227) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:星期几的第一个字母来判断一下是星期几,如果第一个字母一样, 则继续判断第二个字母,直至找到唯一数据。这里我扩展为不限个数任意 一组数据*/ int main(){ int i,k,j1,j2,j3,j4,j5,j6,j7; char a; char w1[]="monday"; char w2[]="tuesday 阅读全文
posted @ 2019-08-29 16:08 狗狗王 阅读(1127) 评论(0) 推荐(0)
摘要:扩展一下 阅读全文
posted @ 2019-08-26 23:16 狗狗王 阅读(2213) 评论(0) 推荐(0)
摘要:#include #include /*题目:有5个人坐在一起,问第五个人多少岁?他说比第4个人大2岁。问第4个人岁数,他说比第3个人大2岁。问 第三个人,又说比第2人大两岁。问第2个人,说比第一个人大两岁。最后问第一个人,他说是10岁。请问第五个人多大?*/ int main(){ int i,age=10; for(i=0;i<4;i++) age=age+2; printf("第五个人岁数... 阅读全文
posted @ 2019-08-26 22:16 狗狗王 阅读(735) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> //题目:递归函数调用方式,将所输入的5个字符,以相反顺序打印出来。 int main(){ int i,l; char a[100]; while(1){ printf("请输入一串字符:"); for(i=0;i<100;i++){ scanf("%c",&a[i]); if(a[i]=='\n') break;} l= 阅读全文
posted @ 2019-08-26 21:59 狗狗王 阅读(1534) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> //题目:用递归法求n的阶乘 int main(){ int n; long int s,a; while(1){ printf("请输入参数n:"); scanf("%d",&n); s=1; for(a=1;a<=n;a++) s=s*a; printf("%d!=%ld\n_______________________ 阅读全文
posted @ 2019-08-26 13:14 狗狗王 阅读(2055) 评论(0) 推荐(0)
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 //题目:求 1+2!+3!+4!……n!的和 4 int main(){ 5 int s,i,n,a,sum; 6 while(1){ 7 printf("请输入参数n:"); 8 scanf("%d",&n); 9 sum=0; 10 for(i=1;i<=n;i++){ 11 s=1; 12 for(a=1 阅读全文
posted @ 2019-08-26 11:44 狗狗王 阅读(1057) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> //题目:2/1,3/2,5/3,8/5,13/8,21/13...求出这个数列的前20项之和 int main(){ int i,n; float a,b,s,t; while(1){ printf("请输入相加项数:"); scanf("%d",&n); s=0; a=2; b=1; for(i=1;i<=n;i++){ 阅读全文
posted @ 2019-08-26 08:54 狗狗王 阅读(2284) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 //题目:打印菱形 4 5 int main(){ 6 int a,b,x,y; 7 x=8; 8 y=8; 9 for(a=1;a<=13;a++){ 10 for(b=1;b<=15;b++) 11 if(b==x||b==y) 12 printf("*"); 13 ... 阅读全文
posted @ 2019-08-26 05:41 狗狗王 阅读(393) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> //两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。有人向队员打 //听比赛的名单。a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。 int main(){ int x=1,y=2,z=3,a,b,c; for(a=1;a<=3;a++) for(b=1;b<= 阅读全文
posted @ 2019-08-25 21:22 狗狗王 阅读(669) 评论(0) 推荐(0)
摘要:#include #include int main(){ int n,i; float s,l; while(1){ printf("请输入天数"); scanf("%d",&n); printf("请输入剩余桃子的个球"); scanf("%f",&l); for(i=1;i<=n;i++){ s=(l+1)*2; l=s; if(i<n) printf("第%d天剩余%f个桃子\n",... 阅读全文
posted @ 2019-08-24 20:43 狗狗王 阅读(832) 评论(0) 推荐(0)
摘要:本题扩展为不固定高度不固定次数(系统输入) 阅读全文
posted @ 2019-08-23 20:46 狗狗王 阅读(936) 评论(0) 推荐(0)
摘要:#include #include #include /*题目:一个数如果恰好等于除开它本身外的因子之和,这个数就称为“完数”。例如6=1+2+3.编程找出1000以内的所有完数*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /... 阅读全文
posted @ 2019-08-23 17:55 狗狗王 阅读(846) 评论(0) 推荐(0)
摘要:#include #include #include /*题目:求s=a+aa+aaa+aaaa+aa...a的值,其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加) ,几个数相加有键盘控制。*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 l... 阅读全文
posted @ 2019-08-23 17:54 狗狗王 阅读(3620) 评论(0) 推荐(0)
摘要:#include #include /*题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /*******************************... 阅读全文
posted @ 2019-08-23 17:53 狗狗王 阅读(3887) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:输入两个正整数m和n,求其最大公约数和最小公倍数*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /************************************ 阅读全文
posted @ 2019-08-23 17:52 狗狗王 阅读(4968) 评论(0) 推荐(0)
摘要:#include #include /*题目:利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A 表示,60-89 分之间的用B 表示,60分以下的用C表示*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /***************... 阅读全文
posted @ 2019-08-23 17:51 狗狗王 阅读(1227) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:将一个正整数分解质因数*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /******************************************程序主体分割线 阅读全文
posted @ 2019-08-23 17:50 狗狗王 阅读(1049) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=50"); //固定显示框尺寸 /***************** 阅读全文
posted @ 2019-08-23 17:48 狗狗王 阅读(2790) 评论(0) 推荐(0)
摘要:【此处扩展为求任意两个数m,n之间的素数及个数】 阅读全文
posted @ 2019-08-23 17:47 狗狗王 阅读(2886) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显 阅读全文
posted @ 2019-08-23 17:46 狗狗王 阅读(683) 评论(0) 推荐(0)
摘要:#include #include /*题目:打印楼梯和笑脸*/ int main() { //system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /******************************************程序主体分割线(顶部)*************... 阅读全文
posted @ 2019-08-23 17:44 狗狗王 阅读(818) 评论(0) 推荐(0)
摘要:#include #include /*题目:输出国际象棋棋盘*/ int main() { //system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /******************************************程序主体分割线(顶部)************... 阅读全文
posted @ 2019-08-23 17:44 狗狗王 阅读(1466) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:输出9*9 口诀。*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /******************************************程序主体分割线(顶 阅读全文
posted @ 2019-08-23 17:42 狗狗王 阅读(814) 评论(1) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:输出特殊图案,请在c 环境中运行,看一看, VeryBeautiful!*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /************************ 阅读全文
posted @ 2019-08-23 17:41 狗狗王 阅读(1985) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:用*号输出字母C的图案*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /******************************************程序主体分割线 阅读全文
posted @ 2019-08-23 17:38 狗狗王 阅读(2957) 评论(0) 推荐(1)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:输入三个整数x,y,z,请把这三个数由小到大输出*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /************************************ 阅读全文
posted @ 2019-08-23 17:37 狗狗王 阅读(3410) 评论(0) 推荐(0)
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 /*题目:输入某年某月某日,判断这一天是这一年的第几天*/ 4 int main() { 5 system("color 1F"); // 设定显示框为蓝底白字 6 system("mode con cols=80 lines=30"); //固定显示框尺寸 7 /************************ 阅读全文
posted @ 2019-08-23 17:35 狗狗王 阅读(4623) 评论(0) 推荐(0)
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 /*题目:一个整数,它加上100 后是一个完全平方数,再加上168 又是一个完全平方数,请问该数是多少?*/ 4 int main() { 5 system("color 1F"); // 设定显示框为蓝底白字 6 system("mode con cols=80 lines=30"); //固定显示框尺寸 7 阅读全文
posted @ 2019-08-23 17:34 狗狗王 阅读(1185) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 /*企业发放的奖金根据利润提成。利润(I)低于或等于10 万元时,奖金可提10%;利润高于10 万元,低于20 万元 4 时,低于10 万元的部分按10%提成,高于10 万元的部分,可可提成7.5%; 20 万到40 万之间时,高于20 万元的部分, 5 可提成5%; 40 万到60 万之间时高于40 万元的部分,可提成3%;60 万到1... 阅读全文
posted @ 2019-08-23 17:33 狗狗王 阅读(5918) 评论(0) 推荐(0)
摘要:1 #include<stdio.h> 2 #include<stdlib.h> 3 int main() //题目:有1、2、3、4 个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? 4 { 5 system("color 1F"); // 设定显示框为蓝底白字 6 system("mode con cols=80 lines=30"); //固定显示框尺寸 7 /********* 阅读全文
posted @ 2019-08-23 17:31 狗狗王 阅读(2321) 评论(0) 推荐(0)
摘要:#include<stdio.h> #include<stdlib.h> /*题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数*/ int main() { system("color 1F"); // 设定显示框为蓝底白字 system("mode con cols=80 lines=30"); //固定显示框尺寸 /**************************** 阅读全文
posted @ 2019-08-23 17:27 狗狗王 阅读(5318) 评论(0) 推荐(0)
摘要:定义 关键字:struct struct 结构体名 { 结构体所包含的变量或数组}; //结尾为分号 struct stu{ char *name; //姓名 int num; //学号 int age; //年龄 char group; //所在学习小组 float score; //成绩 }; 阅读全文
posted @ 2019-08-23 17:24 狗狗王 阅读(1816) 评论(0) 推荐(0)
摘要:一、指针指向变量:(一般指针) 下面有这样一个代码块: int main() {int a=10;int b=15;test(a,b);printf("a=%d,b=%d\n",a,b);} void test(int x,int y) {int tmp;tmp=x;x=y;y=tmp;} 最后输出 阅读全文
posted @ 2019-08-23 17:22 狗狗王 阅读(1718) 评论(0) 推荐(0)
摘要:指针的基本概念和常见用法 * 为指针标识符。 如:*p 格式:datatype *name = value; //定义格式 int *p; //定义,定义时必须带* 。 float *p1 = &a; char *p2 = &c; p1 = &b; p2 = &d; //赋值,在定义的同时赋值需要带 阅读全文
posted @ 2019-08-23 17:21 狗狗王 阅读(1220) 评论(0) 推荐(0)
摘要:(1) 格式说明符中,可以指定数据的宽度,但不能指定数据的精度。例: 1 2 3 float a; scanf(“%10f”,&a); //正确 scanf(“%10.2f”,&a); //错误 float a; scanf(“%10f”,&a); //正确 scanf(“%10.2f”,&a);  阅读全文
posted @ 2019-08-23 17:19 狗狗王 阅读(631) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2019-08-23 17:15 狗狗王 阅读(110) 评论(0) 推荐(0)
摘要:第一个关键字:auto 用来声明自动变量。 可以显式的声明变量为自动变量。只要不是声明在所有函数之前的变量,即使没加auto关键字,也默认为自动变量。并且只在声明它的函数内有效。而且当使用完毕后,它的值会自动还原为最初所赋的值。自动变量使用时要先赋值,因为其中包含的是未知的值。例:auto int 阅读全文
posted @ 2019-08-23 17:14 狗狗王 阅读(1137) 评论(0) 推荐(0)
摘要:#include<stdio.h> int main() { int a,b; while(~scanf("%d%d", &a, &b)) //直接用语句作为循环条件 printf("%d\n",a+b); return 0; } 阅读全文
posted @ 2019-08-23 17:07 狗狗王 阅读(234) 评论(0) 推荐(0)
摘要:printf(“%[flag][width][.precision]typ”e); % 输出符 [flag] .precision 小数点位数 typ 数据类型 width 数据宽度 例如printf(“%-9.7d”e);表示输出e, 左对齐,总共占9个位置,不足的空格补齐,小数点精确到7位(不足 阅读全文
posted @ 2019-08-23 16:38 狗狗王 阅读(872) 评论(0) 推荐(0)
摘要:生成一定范围内的随机数 在实际开发中,我们往往需要一定范围内的随机数,过大或者过小都不符合要求,那么,如何产生一定范围的随机数呢?我们可以利用取模的方法: 如果要规定上下限: 分析:取模即取余,rand()%51+13我们可以看成两部分:rand()%51是产生 0~50 的随机数,后面+13保证 阅读全文
posted @ 2019-08-23 16:26 狗狗王 阅读(17118) 评论(0) 推荐(0)
摘要:1 #include 2 3 int main() 4 5 { 6 7 printf(" 摘苹果代码\n"); 8 9 int a[10],i,b=0,h,c; 10 11 printf("请分别输入小明的身高\n"); 12 13 scanf("%d",&h); 14 15 printf("请输入板凳的高度\n"); 16 17 scanf("%d",... 阅读全文
posted @ 2019-08-23 16:21 狗狗王 阅读(1971) 评论(0) 推荐(0)
摘要:一 system("color a0"); //颜色函数 背景 字体 0 = 黑色 8 = 灰色 1 = 蓝色 9 = 淡蓝色 2 = 绿色 A = 淡绿色 3 = 湖蓝色 B = 淡浅绿色 4 = 红色 C = 淡红色 5 = 紫色 D = 淡紫色 6 = 黄色 E = 淡黄色 7 = 白色 F 阅读全文
posted @ 2019-08-23 16:11 狗狗王 阅读(1070) 评论(0) 推荐(0)
摘要:1 #include <stdio.h> 2 #include <windows.h> 3 int main() 4 { 5 int a=0,b=1; 6 system("color 79"); 7 while(a<=1000) 8 { 9 b=0; 10 system("cls"); 11 while(b<=a) 12 { 13 printf(" "); 14 b=b+1; 15 } 16 Sl 阅读全文
posted @ 2019-08-23 16:05 狗狗王 阅读(326) 评论(0) 推荐(0)
摘要:1 #include <stdio.h> 2 #include <windows.h> 3 int main() 4 { 5 system("mode con cols=50 lines=10"); 6 system("color 79"); 7 int a,b,c; 8 printf("请设定时(大于等于零的整数):"); 9 scanf("%d",&a); 10 printf("请设定分(大于 阅读全文
posted @ 2019-08-23 16:04 狗狗王 阅读(2458) 评论(0) 推荐(0)
摘要:1 #include <stdio.h> 2 #include <windows.h> 3 int main() 4 { 5 system("mode con cols=30 lines=10"); //显示框大小控制函数 6 system("color 79"); //显示颜色控制函数,字体和背景 7 int a=0,b=0,c=0; 8 while(a>=0) 9 { 10 while(a<= 阅读全文
posted @ 2019-08-23 16:00 狗狗王 阅读(5417) 评论(0) 推荐(0)
摘要:<!DOCTYPE html> <dl> <dd> <table><tbody> <tr> <th width="70"> <p style="text-align: left;color: rgb(0, 0, 255);line-height:10px;font-size: 20px">小区名称:</p></th> <td width="150"<p style="font-size: 20p 阅读全文
posted @ 2019-08-23 15:58 狗狗王 阅读(743) 评论(0) 推荐(0)