zoukankan      html  css  js  c++  java
  • <C Primer Plus>12 switch and break continue

    #include <stdio.h>
    #define STOP '#'
    int main(void){
        char ch;
    
        printf("Please input the lower
    ");
        printf("input the # to stop.
    ");
        while ((ch = getchar()) != STOP){
            if (islower(ch)){
                switch (ch){
                case 'a':
                    printf("apple,a fruit of red.
    ");
                    break;
                case 'b':
                    printf("banan, a fruit of yellow.
    ");
                    break;
                case 'c':
                    printf("coati, recoonlike mammal.
    ");
                    break;
                case 'd':
                    printf("desman,aquatic molelike critter.
    ");
                    break;
                case 'e':
                    printf("echidna,the spiny anteater.
    ");
                    break;
                case 'f':
                    printf("fisher ,brownish marten.
    ");
                    break;
                }        
            }
            else{
                printf("I recongnize only lowercase letters.
    ");
            }
            
        }
        printf("Bye!
    ");
        return 0;
    }

    REMEBER:

    1 continue causes the rest of an iteration to be skipped and the next iteration to be started.

    2.break causes the program to break free of the loop that encloses it and to proceed to the next stage of the program.

    3 swtich(integer expression1){

      case constant1:

          statements

          break;//depend on your meaning 

      case constant2:

          statements

          break;

      default:

          statements

          break;

    }

  • 相关阅读:
    python-字典
    C#公历转农历算法
    GridView控件显示图片
    SQLite DBHelp
    面向服务体系结构:适用于敏捷的系统
    针对 .NET 框架的安全编码指南
    Microsoft .NET Pet Shop 4
    C#.NET数据库访问类DBHelper
    Emgu CV 高斯建模
    .NET代码编写规范 整理
  • 原文地址:https://www.cnblogs.com/michael2016/p/6665206.html
Copyright © 2011-2022 走看看