摘要: 1、编写程序,统计字符串中大写字母的个数 #include <stdio.h> main() { char str[80]; int i=0; int cnt=0; printf("请输入你的字母:"); gets(str); while ( str[i]!=0 ) { if ( str[i]>=' 阅读全文
posted @ 2021-11-27 19:34 李治浩 阅读(29) 评论(0) 推荐(0) 编辑
摘要: 1、定义一个含有8个存储单元的实行数组,从键盘上接收数,然后逆序输出 #include <stdio.h> main() { int a[8],i,j; for( i=0;i<8;i++ ) { printf( "请输入第 %d数字",i+1 ); scanf( "%d",&a[i] ); } fo 阅读全文
posted @ 2021-11-27 19:32 李治浩 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 1. 猜数字:随机产生一个0-99的数,猜猜看如果大了就提示大了点如果小了就提示小了点直到猜对为止#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int a,n; srand((unsigned)time(N 阅读全文
posted @ 2021-11-27 19:28 李治浩 阅读(26) 评论(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"); } } 输出一个倒三角形 #include<stdio.h> ma 阅读全文
posted @ 2021-11-09 10:29 李治浩 阅读(28) 评论(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\n",sum); } 2.编写程序,使用while语句求和sum=1 阅读全文
posted @ 2021-11-02 21:19 李治浩 阅读(34) 评论(0) 推荐(0) 编辑
摘要: 1.编码程序判断一个数是正数还是负数. #include<stdio.h> main() { int a; printf("请输入一个数"); scanf("%d",&a); if(a>0) printf("%d是正数",a); else printf("%d是负数",a); } 2.使用条件运算符 阅读全文
posted @ 2021-10-30 20:16 李治浩 阅读(36) 评论(0) 推荐(0) 编辑
摘要: 1.使用switch语句实现分数分级判断 #include<stdio.h> main() { int mark; printf("请输入分数"); scanf("%d",&mark); switch(mark/10) { case 10: case 9: printf("A\n"); break; 阅读全文
posted @ 2021-10-28 23:11 李治浩 阅读(54) 评论(0) 推荐(0) 编辑
摘要: 输入单价,数量,计算总金额,打八折,计算折后价.输入付款金额,计算找零 #include<stdio.h> main(){double price,sum,pay,zhaoling;int num,moling;printf("请输入商品单价\n");scanf("%lf",&price);prin 阅读全文
posted @ 2021-10-16 12:05 李治浩 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 1. 编写程序,使用scanf()函数接收整型,实型,字符型的变量,并分行依次输出。 #include<stdio.h> main() { int a; float b; char c; scanf("%d%f%c",&a,&b,&c); printf("%d\n%f\n%c\n",a,b,c); 阅读全文
posted @ 2021-10-15 18:18 李治浩 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 编写程序,定义两个整形变量你,赋值并输出 #include<stdio.h> main() { int a=2; int b=6; printf("%d %d\n",a,b); } 2.编写程序,定义一个单精度和双精度的变量,赋值并输出 #include<stdio.h> main() { floa 阅读全文
posted @ 2021-10-13 21:58 李治浩 阅读(25) 评论(0) 推荐(0) 编辑