zoukankan      html  css  js  c++  java
  • C Primer Plus_第三章_数据和C_复习题与编程练习

    Review

    long代替int类型变量的原因是什么?
    在您的系统中,long可以容纳比int更大的数;如果您确实需要处理更大的值,那么使用一种在所有系统上都保证至少是32位的类型会使程序的可移植性更好。(PS:用sizeof(int)查看我电脑中的int发现是4字符即32位,和long一样,但是long是标准的32位,int在我这64位的系统中定义的是32位,在其他系统可能是16位。无论如何,有个标准,最好按标准来设定,这样移植起来就方便)

    要获得一个32位的有符号整数,可以使用哪些可以值得数据类型?每种选择的原因是什么?
    要获得正好是32位的数,可以使用int32_t
    要获得可存储至少32位的最小类型,可使用int_least32_t
    要获得32位类型中提供最快计算速度的类型,可选择int_fast32_t


    Practice

    1.略

    2.


    #include
    int main(void)
    {
     //输入一个整数
     int i;
     printf("Please enter the value of i: ");
     scanf("%d",&i);
     printf("i = %d ", i);
     //将这个整数赋给一个字符,自动按照ascii码找到相应的字符
     char c = i;
     printf("the ASCII character of number %d is %c ", i, c);

     return 0;
    }

    3.


    #include
    #include
    #include

    int main(void)
    {
     printf("startled by the sudden sound,a Sally shouted, "By the Great Pumpkin, what was that!" ");
     printf("a");

     return 0;
    }

     

    4.


    #include
    int main(void)
    {
     float f;
     printf("Please enter a float: ");
     scanf("%f", &f);
     printf("f = %f and f also = %e ", f, f);

     return 0;
    }

     

    5.


    #include
    int main(void)
    {
     int i;
     double one_year = 3.156e7;
     printf("My master, please enter your age: ");
     scanf("%d",&i);
     printf("My master, you have been on the earth for about %f seconds! ", i*one_year);

     return 0;
    }

     

    7.


    #include
    int main(void)
    {
     float height;
     float one_inch = 2.54;
     printf("Please enter your height in centimiter my master: ");
     scanf("%f",&height);
     printf("My master, you're %1.2f cm high and that is %1.2f inch, so cool! ", height, height/one_inch);

     return 0;
    }

  • 相关阅读:
    消息队列技术
    NET Core中使用Apworks
    TCP基础
    Oracle停止一个JOB
    如何在Java 8中愉快地处理日期和时间
    mysql字符串区分大小写的问题
    【已解决】javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint
    spring boot 1.4默认使用 hibernate validator
    mysql shell
    android:background="@drawable/home_tab_bg"
  • 原文地址:https://www.cnblogs.com/TomLily/p/5814586.html
Copyright © 2011-2022 走看看