- /*------------------------------------------------------------------
- * ------------------------- scanf 练习 ---------------------------
- *----------------------------------------------------------------- */
- /*
- #include<stdio.h>
- int main()
- {
- int a;
- printf("请输入一个整数");
- scanf("%d",&a);
- printf("%d\n",a);
- return 0;
- }*/
- /*&
- # include<stdio.h>
- int main()
- {
- int a,b;
- printf("请输入一个加法格式为:1 + 2:");
- scanf("%d + %d",&a,&b);
- printf("%d + %d = %d\n",a,b,a+b);
- }
- */
- /*-----------------------------------------------------
- *------------------ sizeof 练习----------------------
- *--------------------------------------------------- */
- /*#include<stdio.h>
- int main()
- {
- 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);
- return 0;
- }*/
- /*=======================================================
- * 进制练习
- *======================================================
- * */
- /*#include<stdio.h>
- int main()
- {
- printf("%d %d %d\n",12,012,0x12);
- printf("%d 0%o 0x%x\n",18,18,18);
- printf("%p\n",18);
- return 0;
- }*/
- /*============================================================
- * 二进制练习
- *========================================================= */
- /*#include<stdio.h>
- int main()
- {
- int shu_zi = 300;
- unsigned char zi_fr =shu_zi;
- }
- */
- /*=============================================================
- * 操作符练习
- *========================================================== */
- #include<stdio.h>
- int main()
- {
- 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;//先计算加法在计算自乘,因为乘法和赋值一起使用时,会把优先级降到和赋值一样。
- printf("shu_zi是%d\n",shu_zi);
- return 0;
- }
/*------------------------------------------------------------------ * ------------------------- scanf 练习 --------------------------- *----------------------------------------------------------------- */ /* #include<stdio.h> int main() { int a; printf("请输入一个整数"); scanf("%d",&a); printf("%d\n",a); return 0; }*/ /*& # include<stdio.h> int main() { int a,b; printf("请输入一个加法格式为:1 + 2:"); scanf("%d + %d",&a,&b); printf("%d + %d = %d\n",a,b,a+b); } */ /*----------------------------------------------------- *------------------ sizeof 练习---------------------- *--------------------------------------------------- */ /*#include<stdio.h> int main() { 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); return 0; }*/ /*======================================================= * 进制练习 *====================================================== * */ /*#include<stdio.h> int main() { printf("%d %d %d\n",12,012,0x12); printf("%d 0%o 0x%x\n",18,18,18); printf("%p\n",18); return 0; }*/ /*============================================================ * 二进制练习 *========================================================= */ /*#include<stdio.h> int main() { int shu_zi = 300; unsigned char zi_fr =shu_zi; } */ /*============================================================= * 操作符练习 *========================================================== */ #include<stdio.h> int main() { 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;//先计算加法在计算自乘,因为乘法和赋值一起使用时,会把优先级降到和赋值一样。 printf("shu_zi是%d\n",shu_zi); return 0; }
- /*------------------------------------------------------------------
- * ------------------------- scanf 练习 ---------------------------
- *----------------------------------------------------------------- */
- /*
- #include<stdio.h>
- int main()
- {
- int a;
- printf("请输入一个整数");
- scanf("%d",&a);
- printf("%d\n",a);
- return 0;
- }*/
- /*&
- # include<stdio.h>
- int main()
- {
- int a,b;
- printf("请输入一个加法格式为:1 + 2:");
- scanf("%d + %d",&a,&b);
- printf("%d + %d = %d\n",a,b,a+b);
- }
- */
- /*-----------------------------------------------------
- *------------------ sizeof 练习----------------------
- *--------------------------------------------------- */
- /*#include<stdio.h>
- int main()
- {
- 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);
- return 0;
- }*/
- /*=======================================================
- * 进制练习
- *======================================================
- * */
- /*#include<stdio.h>
- int main()
- {
- printf("%d %d %d\n",12,012,0x12);
- printf("%d 0%o 0x%x\n",18,18,18);
- printf("%p\n",18);
- return 0;
- }*/
- /*============================================================
- * 二进制练习
- *========================================================= */
- /*#include<stdio.h>
- int main()
- {
- int shu_zi = 300;
- unsigned char zi_fr =shu_zi;
- }
- */
- /*=============================================================
- * 操作符练习
- *========================================================== */
- #include<stdio.h>
- int main()
- {
- 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;//先计算加法在计算自乘,因为乘法和赋值一起使用时,会把优先级降到和赋值一样。
- printf("shu_zi是%d\n",shu_zi);
- return 0;
- }