zoukankan      html  css  js  c++  java
  • 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);

  • 相关阅读:
    cart树剪枝
    LSA、LDA
    paddle中新增layer
    https://www.i5seo.com/
    打印机彩色打印设置(将彩色打印为黑色)
    办公文档的标准格式
    电脑常用的5个按键
    Win7各个版本之间的区别
    win7保护眼睛的颜色设置方法(85,125,205)
    详细教您台式电脑如何组装
  • 原文地址:https://www.cnblogs.com/hmzxwky/p/5017216.html
Copyright © 2011-2022 走看看