随笔分类 - c语言例子
摘要:#include <stdio.h> /* 本题结果为:-4 short类型占据2字节 ;赋值后实际占据了3个字节,所以有溢出警告提示,结果只保留0xfffc 保存二进制:1111 1111 1111 1100 (补码) 减1: 1111 1111 1111 1011 取反: 1000 0000 0
阅读全文
摘要:#include <stdio.h> #include <time.h>//声明time 时间不可逆转一直在变 #include <math.h> #include <stdlib.h> //<stdlib.h>用于调用 rand(), main() { srand((unsigned)time(0
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> //<stdlib.h>用于调用 rand(), #include <time.h> //声明time 时间不可逆转一直在变 #include <Windows.h> //<Windows.h> 用于清屏 #include
阅读全文
摘要:1.自动类型转换:将小范围数据类型转换为大范围的数据类型 2.赋值号两边的数据类型不一致时,会自动将右边的数据类型转换为左边的数据类型。若右边数据的类型级别高,则根据左边变量的长度截取低字节数据部分 int a=259;char b;b=a;//(a=259-256=3) int a=266;cha
阅读全文
摘要:#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
阅读全文
摘要:#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); /
阅读全文
摘要:#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
阅读全文
摘要:#include <stdio.h> int main(){ char c; //用户输入的字符 int shu=0;//字符总数 int letters=0, // 字母数目 space=0, // 空格数目 digit=0, // 整数数目 others=0; // 其他字符数目 printf(
阅读全文
摘要:#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
阅读全文

浙公网安备 33010602011771号