胡超亮吧 关注:13贴子:370
  • 3回复贴,共1

【大一笔记】程序设计基础

取消只看楼主收藏回复





1楼2013-09-14 09:55回复
    hello.c
    /* * File: hello.c
    * --------------
    * This program prints the message "Hello, world."
    * on the screen. The program is taken from the
    * classic C reference text "The C Programming
    * language" by Brian Kernighan ang Dennis Ritchie.
    */
    #include <stdio.h>
    #include "genlib.h"
    main()
    {
    printf("Hello, world.\n");
    getchar();
    }


    2楼2013-09-26 17:44
    回复
      add2.c
      /* *file:add2.c
      *-----------
      *This program reads in two numbers, adds them together,
      *and prints their sum.
      */
      #include <stdio.h>
      #include "genlib.h"
      #include "simpio.h"
      main()
      {
      int n1, n2, total;
      printf("this program adds two numbers.\n");
      printf("1st number? ");
      n1 = GetInteger();
      printf("2nd number? ");
      n2 = GetInteger();
      total = n1 + n2;
      printf("The total is %d.\n", total);
      getchar();
      }


      3楼2013-09-26 17:54
      回复
        表示输出类型的格式字符 格式字符意义
        d 以十进制形式输出带符号整数(正数不输出符号)
        o 以八进制形式输出无符号整数(不输出前缀O)
        x 以十六进制形式输出无符号整数(不输出前缀OX)
        u 以十进制形式输出无符号整数
        f 以小数形式输出单、双精度实数
        e 以指数形式输出单、双精度实数
        g 以%f%e中较短的输出宽度输出单、双精度实数
        c 输出单个字符
        s 输出字符串


        4楼2014-01-02 20:23
        回复