• 12月3号 命名规范和运算符的使用


    //命名规范

    (大小写字符、数字、下划线_)

    必须是字母开头

    当有多个单词组成的变量名中,第一个单词小写  第二个单词首字母大写

    能够见名知义

    //声明一个变量:系统不会立刻分配内存空间

    //定义一个变量:立刻分配内存空间,然后将值保存

    printf向终端输出

      输出的是字符串 printf("");

     向终端输出:"It's delicious ?",she asked!

     要用到转义字符

    scanf 从终端接收输出

       1.输入的内容必须是严格按照scanf内部的格式输入

       int  a,b;

       scanf("%d %d", &a, &b);

       输出格式

       12 34

      

       int  a,b;

      scanf("%d&%d", &a, &b);

      输出格式

      12&34

    2.scanf参数必须是变量的地址(&表示地址)

      scanf("%c", &operation);

    getchar() 从终端一次接收一个字符

    运算符

    + - *

    取整

        int average = totalCake / totalMan;

        int left = totalCake % totalMan;

       printf("%d cakes for %d man, each man get %d, %d left! ",totalCake, totalMan, average, left);

    类型的优先级 short->int->long->float->double

    类型转换分为两种

    //强制转换(float) totalCake

    float result = (float)totalCake / totalMan;

    //自动转换

    float result = 1.0*totalCake / totalMan;

         /* 

         ++   自动+1

         a++  延迟+1,当语句执行完毕之后再加1

         ++a  立刻+1

         */

        int temp = 10;

        int re = (temp++) + 20;

     

        printf("%d ", re);    

        printf("temp = %d ", temp++);  

        printf("after temp = %d ", temp);   

        printf("temp = %d after = %d ", temp++, temp);  

        

        int a = 20;

        int b = (++a) + 20;

        printf("a=%d b=%d ", a, b);

  • 相关阅读:
    python 展开嵌套列表
    python对字典排序
    CentOS7 Network Setting
    华为交换机Stelnet ssh/rsa验证模式下16进制公钥生成方法
    CentOS7 DHCP自动获取IP地址
    拔掉网线才能登陆域
    Exchange日志清理
    Exchange日志
    EMS邮箱数据库常用命令(二)
    EMS邮箱数据库常用命令(一)
  • 原文地址:https://www.cnblogs.com/hmzxwky/p/5017216.html
Copyright © 2020-2023  润新知