摘要:
1.统计字符串中字符的长度。 #include<stdio.h> main(){ char str[100]; int i=0,j=0; gets(str); puts(str); while(str[i++]!='\0') j++; printf("字符串长度为%d\n",j); } 3.编写程序 阅读全文
posted @ 2021-11-24 16:44
金袁媛
阅读(45)
评论(0)
推荐(0)
摘要:
1.定义一个含有8个存储单元的实型数组,从键盘上接收数,然后逆序输出。#include<stdio.h> main() { int m[8]; int i; for(i=0;i<=7;i++) scanf("%d",&m[i]); for(i=7;i>=0;i--) printf("%d",m[i] 阅读全文
posted @ 2021-11-24 16:37
金袁媛
阅读(36)
评论(0)
推荐(0)
摘要:
1.猜数字,随机产生一个0-99的数,猜猜看如果大了就提示大了点如果小了就提示小了点,直到猜对为止 #include<stdio.h> #include<stdlib.h> #include<time.h> int main(){ int a,n; srand((unsigned)time(NULL 阅读全文
posted @ 2021-11-24 16:29
金袁媛
阅读(34)
评论(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-24 15:39
金袁媛
阅读(32)
评论(0)
推荐(0)
浙公网安备 33010602011771号