D语言嵌套的switch语句

import std.stdio;

int main () { 
   /* local variable definition */ 
   int a = 100; 
   int b = 200;  

   switch(a) {
      case 100: 
         writefln(This is part of outer switch, a ); 
         switch(b) { 
            case 200: 
               writefln(This is part of inner switch, a ); 
            default: 
               break; 
         } 
      default: 
      break; 
   } 
   writefln(Exact value of a is : %d, a ); 
   writefln(Exact value of b is : %d, b ); 

   return 0; 
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


// ------------------- import std.stdio; void main(string[] args) { writeln("Hello World!");
import std.stdio; int main () { /* local variable definition */ int a = 10; /* while loop execution */
import std.stdio; int main(string[] args) { int a = 20; int b = 10; int c = 15; int d = 5; int e; e = (a + b) * c / d;// ( 30 * 15 ) / 5
import std.stdio; int main(string[] args) { int a = 4; short b; double c; int* ptr; /* example of sizeof operator */
import std.stdio; int main(string[] args) { int a = 21; int c ; c =a; writefln("Line 1 - =Operator Example, Value of c = %d\\n", c );
import std.stdio; int main(string[] args) { uint a = 60; /* 60 = 0011 1100 */ uint b = 13; /* 13 = 0000 1101 */
import std.stdio; int main(string[] args) { int a = 5; int b = 20; int c ; if ( a && b ) { writefln("Line 1 - Condition is true\\n" );
import std.stdio; int main(string[] args) { int a = 21; int b = 10; int c ; if( a == b ) { writefln("Line 1 - a is equal to b\\n" );
import std.stdio; int main(string[] args) { int a = 21; int b = 10; int c ; c = a + b; writefln("Line 1 - Value of c is %d\\n", c );
import std.stdio; int main(string[] args) { writefln("Hello\\tWorld%c\\n",'\\x21');
import std.stdio; enum { A = 1.2f,// A is 1.2f of type float B,// B is 2.2f of type float int C = 3, // C is 3 of type int
import std.stdio; enum : string { A = "hello", B = "world", } int main(string[] args) {
import std.stdio; // Initialized sun with value 1 enum { sun , mon, tue, wed, thu, fri, sat }; int main(string[] args) {
import std.stdio; // Initialized sun with value 1 enum Days { sun = 1, mon, tue, wed, thu, fri, sat };
import std.stdio; enum Days { sun, mon, tue, wed, thu, fri, sat }; int main(string[] args) { Days day; day = Days.mon;
import std.stdio; int main() { writeln("Length in bytes: ", char.sizeof); return 0; }
import std.stdio; int main() { writeln("Length in bytes: ", float.sizeof); return 0; }
// --------------------- import std.stdio; int main() { writeln("Length in bytes: ", ulong.sizeof);
import std.stdio; int a = 10, b = 10; int c; float f; int main () { writeln("Value of a is : ", a);
import std.stdio; void main(string[] args) { char[9] greeting1 = "Hello all"; writefln("%s",greeting1);