摘要: 1使用函数,求2个数的最大值,并调用 #include<stdio.h> int Max(int x,int y) { int r; if(x>y) r=x; else r=y; return r; } int main() { int a,b,c; printf("input a b:"); sc 阅读全文
posted @ 2021-11-27 11:46 赵雅萌 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 1 用循环求字符串长度 #include<stdio.h> #include<string.h> main(){ int i=0; char str[50]="wo ai c yuyan"; while(str[i]!='\0'){ i++; } printf("%d\n",i); 2 编写程序,去 阅读全文
posted @ 2021-11-23 20:29 赵雅萌 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 1定义一个含有八个存储单元的实型数据,从键盘上接收数,然后逆行输出。 #include<stdio.h> main() { int number[8]; int i; for(i=1;i<8;i++){ scanf("%d",&number[i]); } for(i=7;i>=1;i--){ pri 阅读全文
posted @ 2021-11-16 10:32 赵雅萌 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 1 猜数字 #include <stdio.h> #include <stdlib.h> #include <time.h> main(){ int x,guess; srand((unsigned int)time(NULL)); guess=rand()%100; while(1){ print 阅读全文
posted @ 2021-11-12 18:12 赵雅萌 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> main() { int i,j; for(i=1;j<=5;i++){ for(j=1;j<=i;j++){ printf("*"); } printf("\n"); } } 2 #include<stdio.h> main() { int i,j,k; f 阅读全文
posted @ 2021-11-09 10:15 赵雅萌 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 1 编写程序,使用while语句求和sum=1+3+5+...+21. #include<stdio.h> main() { int i=1,sum=0; while(i<=21){ sum+=i; i+=2; } printf("和是%d",sum); } 2 编写程序,使用while语句求sum 阅读全文
posted @ 2021-11-03 15:00 赵雅萌 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 1 编写程序,判断n是正数还是负数。 #include<stdio.h> main() { int n; printf("请输入一个数"); scanf("%d",&n); if(n>0) printf("n是正数"); else printf("n是负数"); } 2 使用条件运算符,找出a,b, 阅读全文
posted @ 2021-10-30 11:31 赵雅萌 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 1 例4-8 #include<stdio.h> main() { int mark; printf("输入学生的分数(0-100):"); scanf("%d",&mark); switch(mark/10) { case 10: case 9:printf("A\n"); break; case 阅读全文
posted @ 2021-10-28 20:42 赵雅萌 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 1 编写程序,判断一个数n是正数还是负数。 #include<stdio.h> main() { float n; scanf("%f",&n); if(n>0) printf("正数!\n"); else if(n==0) printf("0既不是正数也不是负数"); else printf("负 阅读全文
posted @ 2021-10-23 20:24 赵雅萌 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 1 编写程序,定义两个整型变量,赋值并输出。 #include<stdio.h> main() { int a=2; int b=6; printf("%d%d\n",a,b); } 2 编写程序,定义一个单精准度和一个双精准度的变量,赋值并输出。 #include<stdio.h> main() 阅读全文
posted @ 2021-10-16 16:01 赵雅萌 阅读(251) 评论(0) 推荐(0) 编辑