摘要: 1、编写程序,定义两个整形变量,赋值并输出。 #include<stdio.h> main() { int a=1,b=2; printf("%d\n%d\n",a,b); } 2. 编写程序,定义一个单精度和一个双精度的变量,赋值并输出。 #include<stdio.h> main() { fl 阅读全文
posted @ 2021-11-30 21:48 hlstcl 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 1.实现一个菜单. #include <stdio.h> #include <string.h> void mainMenu(); void login(); void regist(); void shuiXianHua(); void returnToMenu(); main() { mainM 阅读全文
posted @ 2021-11-29 22:05 hlstcl 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,将输入的分数mark(0~100)转换为相应的等级(90-100)为A,(80-89)为B,(70-79)为C,(60-69)为D,(0~59)为NO PASS! #include<stdio.h> main() { int mark; printf("输入学生的分数(0-100):" 阅读全文
posted @ 2021-11-23 22:23 hlstcl 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序判断n是正数还是负数 #include <stdio.h> main() { double n; printf("请输入一个值n="); scanf("%lf",&n); if (n>0){ printf("n是正数"); }else if (n<0){ printf("n是负数"); 阅读全文
posted @ 2021-11-23 22:08 hlstcl 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 1、使用while语句求和sum=1+3+5+……+21 #include<stdio.h> main() { int a=1,sum=0; while(a<=21){ if (a%2!=0){ printf("%d ",a); sum+=a; } a++; } printf("\n从1到21的奇数 阅读全文
posted @ 2021-11-23 21:58 hlstcl 阅读(16) 评论(0) 推荐(0) 编辑
摘要: 1 统计字符串中各个数字字符的个数 #include<stdio.h> main() { char str[80]; int i=0; int length=0; gets(str); puts(str); while(str[i++]!='\0') length++; printf("字符串的长度 阅读全文
posted @ 2021-11-23 21:45 hlstcl 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 1.判断一个数n是正数还是负数 #include<stdio.h> main() { float n; printf("请输入一个数"); scanf("%f",&n); if (n>0){ printf("正数\n"); }else if (n==0){ printf("输出的数为0\n"); } 阅读全文
posted @ 2021-11-22 22:35 hlstcl 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 1.输出图形 #include <stdio.h> main() { int i,j; for(i=1;i<=5;i++) { for(j=1;j<=i;j++) { printf("*"); } printf("\n"); } } 2..输出图形 #include <stdio.h> main() 阅读全文
posted @ 2021-11-22 22:07 hlstcl 阅读(12) 评论(0) 推荐(0) 编辑
摘要: 1.编写程序,输出“我爱学习C语言!” #include<stdio.h> main() { printf("我爱C语言!\n"); } 2..分行输出自己的专业和姓名 #include<stdio.h>main(){ printf("信息与控制工程系\n计算机科学技术\n何雨时");} 3.用*号 阅读全文
posted @ 2021-11-22 21:57 hlstcl 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 1. 猜数字:随机产生一个0-99的数,猜猜看如果大了就提示大了点如果小了就提示小了点直到猜对为止 #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int a,n; srand((unsigned)time( 阅读全文
posted @ 2021-11-22 21:47 hlstcl 阅读(6) 评论(0) 推荐(0) 编辑