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);

  • 相关阅读:
    uva 10369 Arctic Network
    uvalive 5834 Genghis Khan The Conqueror
    uvalive 4848 Tour Belt
    uvalive 4960 Sensor Network
    codeforces 798c Mike And Gcd Problem
    codeforces 796c Bank Hacking
    codeforces 768c Jon Snow And His Favourite Number
    hdu 1114 Piggy-Bank
    poj 1276 Cash Machine
    bzoj 2423 最长公共子序列
  • 原文地址:https://www.cnblogs.com/hmzxwky/p/5017216.html
Copyright © 2011-2022 走看看