摘要: #include <stdio.h> main() { char s[]="012xy\08s34f4w2"; //ascii码0对应的字符为空字符 //本来\08可以理解为1个字符,但8不是8进制数,斜线只能转义0 //当循环到\0时,循环条件不成立,则退出循环 int i,n=0; for(i= 阅读全文
posted @ 2022-10-06 17:05 myrj 阅读(120) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <string.h> main() { char a[10]="abc",b[10]="012",c[10]="xyz"; strcpy(a+1,b+2);//b+2对应的字符2\0,结果bc改为2\0 ,所以a结果为a2 puts(strca 阅读全文
posted @ 2022-10-06 16:51 myrj 阅读(29) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <string.h> main() { char ab[100]="asdfasd",ac[100]; printf("%d %d\n",ab,ac); //ac=ab 由于ab,ac分别为两个数组的起始地址,所以该句有语法问题 //字符数组相 阅读全文
posted @ 2022-10-06 16:32 myrj 阅读(331) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <math.h> //三角函数的参数为弧度,是角度必须转化为弧度 //3.14=180,1度=3.14/180,转化方法:(3.14/180)*角度值 main() { float a,b,c; c=30; printf("%f",sin(c) 阅读全文
posted @ 2022-10-06 16:19 myrj 阅读(429) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> main() { int a,b,c; for(a=1;a<110;a++) printf("%d ",rand()%10) ; getchar(); } 第一次运行: 第二次运行: 结果相同 一般srand和rand配合使用产生伪随机数序列。rand函数在产生 阅读全文
posted @ 2022-10-06 16:07 myrj 阅读(447) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> //为小学一年级学生随机出10道题,加法或减法随机出现,保证涉及到的数在0-9之间,结果不能出现负数 //程序运行输入结果后提示对或错,最后并统计做对了几道题,及最后得分(每题10分计算) #include <math.h> main() { int i,a,b 阅读全文
posted @ 2022-10-06 15:43 myrj 阅读(137) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> main() { int a,b,c,i; for(a=1;a<=9;a++) for(b=0;b<=9;b++) for(c=0;c<=9;c++) if(a*a*a+b*b*b+c*c*c==a*100+b*10+c) printf("%d ",a*100+ 阅读全文
posted @ 2022-10-06 09:44 myrj 阅读(363) 评论(0) 推荐(0) 编辑