/*------------------------------------------------------------------
------------------------- scanf 练习 ---------------------------
----------------------------------------------------------------- /
/*include
int main()
{ //代码效果参考:http://www.zidongmutanji.com/bxxx/51858.htmlint a;
printf("请输入一个整数");
scanf("%d",&a);
printf("%d\n",a);
return 0;
}/
/&include
int main()
{
int a,b;
printf("请输入一个加法格式为:1 + 2:");
scanf("%d + %d",&a,&b);
printf("%d + %d = %d\n",a,b,a+b);
}
/
/-----------------------------------------------------
------------------ sizeof 练习---------------------- --------------------------------------------------- /
/#include
char zi_fu = 0;
unsigned char u_zi_fu = 0;
printf("变量zi_fu占%d个字节\n",sizeof(zi_fu));
printf("char类型变量占%d个字节\n",sizeof(char));printf("变量zi_fu占%d个字节\n",sizeof(u_zi_fu));
printf("unsigned char类型变量占%d个字节\n",sizeof(unsigned char));
zi_fu='a';
sizeof(zi_fu='b');
printf("%c\n",zifu);
/*=======================================================- 进制练习
*====================================================== - */
printf("%d %d %d\n",12,012,0x12);
printf("%d 0%o 0x%x\n",18,18,18);
printf("%p\n",18);
/*============================================================
- 二进制练习
========================================================= /
int shu_zi = 300;
unsigned char zi_fr =shu_zi;
/*============================================================= 操作符练习
========================================================== /include
int main()
{ //代码效果参考:http://www.zidongmutanji.com/bxxx/32526.htmlint shu_zi=0,shu_zi1=0;
printf("15/7=%d\n",15/7);//整数类型的运算只保留整数部分。
printf("15 %% 7=%d\n",15%7);
shu_zi = shu_zi1=7;//取决于运算顺序,如果从左往右则变量值会不同,但实际计算机是以右往左赋值。
printf("%d %d\n",shu_zi,shu_zi1);
shu_zi +=2;//相当于shu_zi = shu_zi = 2
printf("shu_zi是%d\n",shu_zi);
shu_zi = 2+3;//先计算加法在计算自乘,因为乘法和赋值一起使用时,会把优先级降到和赋值一样。
return 0;
}
/------------------------------------------------------------------------------------------- scanf 练习 ---------------------------
----------------------------------------------------------------- /
/*include
int main()
{
int a;
printf("请输入一个整数");
scanf("%d",&a);
printf("%d\n",a);
return 0;
}/
/&include
int main()
{
int a,b;
printf("请输入一个加法格式为:1 + 2:");
scanf("%d + %d",&a,&b);
printf("%d + %d = %d\n",a,b,a+b);
}
/
/-----------------------------------------------------
------------------ sizeof 练习---------------------- --------------------------------------------------- /
/#include
char zi_fu = 0;
unsigned char u_zi_fu = 0;
printf("变量zi_fu占%d个字节\n",sizeof(zi_fu));
printf("char类型变量占%d个字节\n",sizeof(char));printf("变量zi_fu占%d个字节\n",sizeof(u_zi_fu));
printf("unsigned char类型变量占%d个字节\n",sizeof(unsigned char));
zi_fu='a';
sizeof(zi_fu='b');
printf("%c\n",zifu);
/*=======================================================- 进制练习
*====================================================== - */
printf("%d %d %d\n",12,012,0x12);
printf("%d 0%o 0x%x\n",18,18,18);
printf("%p\n",18);
/*============================================================
- 二进制练习
========================================================= /
int shu_zi = 300;
unsigned char zi_fr =shu_zi;
/*============================================================= - 操作符练习
========================================================== /
int shu_zi=0,shu_zi1=0;
printf("15/7=%d\n",15/7);//整数类型的运算只保留整数部分。
printf("15 %% 7=%d\n",15%7);
shu_zi = shu_zi1=7;//取决于运算顺序,如果从左往右则变量值会不同,但实际计算机是以右往左赋值。
printf("%d %d\n",shu_zi,shu_zi1);
shu_zi +=2;//相当于shu_zi = shu_zi = 2
printf("shu_zi是%d\n",shu_zi);
shu_zi *= 2+3;//先计算加法在计算自乘,因为乘法和赋值一起使用时,会把优先级降到和赋值一样。