icing

导航

实验2

一、实验结论

Part1:

a. %d :用于十进制整数输入输出;%5d限制了整数宽度为5,当数据长度<5时,左补空格,否则按实际输出;

b. %f  :  用于浮点数输入输出;%lf表示指定输出精度为double型;%.3f表示输出浮点数时控制小数位数为3位;%6.2f表示浮点数输入时数据宽度为6,输出时数据宽度为6且小数位数为2位;

c.  %c : 表示按字符输出;

d. %e : 表示按指数形式输出;

e. %s : 表示按字符串输出;

f. 在使用scanf()输入double类型的数时必须使用%lf 。

 

Part4:

1.

#include<stdio.h>    

  int main()

{         
    char I;
    printf("请输入你的答案(A,B,C or D):");
    scanf("%c",&I);
    switch(I)
    {
        case'A':printf("binggo,you are right~ :)\n");break;
        default:printf("try again~ :(\n");
    }
    return 0;
}

 

 2.

#include<stdio.h>

  int main()

{
    int level;
    printf("输入现在状态等级(1~5):");
    scanf("%d",&level);
    switch(level)
    {
        case 1 :printf("high翻了:)\n");
        case 2 :printf("low爆了:(\n");
        default : printf("一言难尽,无法概括。。。\n");
     } 
    return 0;
}

 

Part5:

 

#include<stdio.h>
int main()
{
    char I;
    printf("请输入你的答案(A,B,C or D):");
    scanf("%c",&I);
    switch(I)
    {
        case'A':printf("binggo,you are right~ :)\n");break;
        default:printf("try again~ :(\n");
    }
    return 0;
}

 

        

 

实验总结与体会

本次实验中主要出现的错误:

1. 规则格式记忆不牢,出现低级错误,如忘记框架中的符号;

2.在面对多分支时不能很好找到对应逻辑关系。;

3.对每种格式符在运用时的特点掌握不深。

 

 

 

 

 

 

posted on 2019-03-31 21:59  icing  阅读(103)  评论(0编辑  收藏  举报