• 有关continue的小程序(1)


    看一个 continue的程序

    c prim plus 7.9

     1 #include<stdio.h>
     2 #include<ctype.h>
     3 int main(void)
     4 {    char ch;
     5     printf("        You give me a letter,
            and I give you a word;
    "
     6            "        Input  a # to quit
    ");
     7     while((ch=getchar())!='#')
     8     {
     9         if('
    ' == ch) continue; //处理刚开始输入的换行符 
    10         
    11         if(islower(ch))
    12             switch(ch)
    13             {
    14                 case 'a': printf("apple
    "); break;
    15                 case 'b': printf("basketball
    "); break;
    16                 case 'c': printf("cell
    "); break;
    17                 case 'd': printf("desirable
    "); break;
    18                 case 'e': printf("elements
    "); break;
    19                 case 'f' :printf("fisher, brownish marten
    ");break;
    20                 default: printf("this is a beautiful world!
    "); break;
    21             }
    22         else
    23             printf("Input a lowercase letter.
    ");
    24     
    25     /*读取并丢弃输入,直至一行的末尾*/
    26     while( getchar()!='
    ') continue; //跳过输入行的剩余部分 
    27         
    28         printf("Input another letter
    ");
    29         printf("----------------------
    ");        
    30             
    31     }
    32     printf("Bye····
    "); 
    33     return 0;
    34 }

    实验结果如下:

    范的错误,我第9行 

    if('
    ' == ch) continue;   刚开始写为了 if('
    ' == getchar()) continue; 这样呢,比如输入 两个字符,才能进入switch···呜呜呜····以后注意哦···
  • 相关阅读:
    获取Finacial dimension value的description 值
    创建一个List获取数据的lookup
    定位form光标行
    Business Unit Lookup in Form
    Linu各种版本
    redis的具体使用
    php中date()函数使用的方法
    Spring整合Hibernate中自动建表
    Android之手机电池电量应用
    SSH整合时,关于访问数据库的load的错误
  • 原文地址:https://www.cnblogs.com/kalo1111/p/3277805.html
Copyright © 2020-2023  润新知