随笔分类 -  c语言例子

上一页 1 ··· 14 15 16 17 18
摘要:#include <stdio.h> /* 本题结果为:-4 short类型占据2字节 ;赋值后实际占据了3个字节,所以有溢出警告提示,结果只保留0xfffc 保存二进制:1111 1111 1111 1100 (补码) 减1: 1111 1111 1111 1011 取反: 1000 0000 0 阅读全文
posted @ 2021-06-18 06:33 myrj 阅读(220) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <time.h>//声明time 时间不可逆转一直在变 #include <math.h> #include <stdlib.h> //<stdlib.h>用于调用 rand(), main() { srand((unsigned)time(0 阅读全文
posted @ 2021-06-17 07:05 myrj 阅读(149) 评论(0) 推荐(0)
摘要:#include <stdio.h> #include <stdlib.h> //<stdlib.h>用于调用 rand(), #include <time.h> //声明time 时间不可逆转一直在变 #include <Windows.h> //<Windows.h> 用于清屏 #include 阅读全文
posted @ 2021-06-16 07:21 myrj 阅读(513) 评论(0) 推荐(0)
摘要:1.自动类型转换:将小范围数据类型转换为大范围的数据类型 2.赋值号两边的数据类型不一致时,会自动将右边的数据类型转换为左边的数据类型。若右边数据的类型级别高,则根据左边变量的长度截取低字节数据部分 int a=259;char b;b=a;//(a=259-256=3) int a=266;cha 阅读全文
posted @ 2021-06-15 09:37 myrj 阅读(369) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main() { int a,b; //方法一:借助第三个变量 int t; a=1,b=2; t=a; a=b; b=t; printf("%d,%d\n",a,b); //方法二 :先保存两数之和 a=1,b=2; a=a+b; b=a-b; a=a 阅读全文
posted @ 2021-06-15 08:35 myrj 阅读(761) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main() { int a,b,c,t; /*定义4个基本整型变量a、b、c、t*/ printf("Please input a,b,c:\n"); /*双引号内的普通字符原样输出并换行*/ scanf("%d,%d,%d",&a,&b,&c); / 阅读全文
posted @ 2021-06-15 06:29 myrj 阅读(666) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main() { int a,b,c,m,t; printf("请输入两个数:\n"); scanf("%d%d",&a,&b); if(a<b) { t=a; a=b; b=t; } m=a*b; c=a%b; while(c!=0) { a=b; b 阅读全文
posted @ 2021-06-14 10:24 myrj 阅读(237) 评论(0) 推荐(0)
摘要:#include <stdio.h> int main(){ char c; //用户输入的字符 int shu=0;//字符总数 int letters=0, // 字母数目 space=0, // 空格数目 digit=0, // 整数数目 others=0; // 其他字符数目 printf( 阅读全文
posted @ 2021-06-14 09:35 myrj 阅读(2608) 评论(0) 推荐(0)
摘要:#include <stdio.h> main() { int a,s,d; s=2,d=3; a=12+(s+2,d+4); printf("%d\n",a); int x,y,z; x=(y=3,(z=++y +2)+5); printf("%d,%d,%d\n",x,y,z); int b=2 阅读全文
posted @ 2021-06-06 09:08 myrj 阅读(300) 评论(0) 推荐(0)

上一页 1 ··· 14 15 16 17 18