Skip to content

Latest commit

 

History

History
51 lines (43 loc) · 688 Bytes

File metadata and controls

51 lines (43 loc) · 688 Bytes

a

//每个case都未设置break,会导致所有条件都执行
switch (ch) {
	case 'a':
		aCnt++;
		break;
	case 'e':
		eCnt++;
		break;
	default:
		iouCnt++
		break;
}

b

//ix变量会由条件跳转而变得未定义
int ix;
switch (index) {
	case 1:{
		ix = get_value();
		ivec[ix] = index;
		break;
	}
	default:{
		ix = ivec.size() - 1;
		ivec[ix] = index;
	}
}

c

//case标签必须是整型常量表达式
case 1: case 3: case 5: case 7: case 9:
case 2: case 4: case 6: case 8: case 10:

d

//case标签必须是整型常量表达式
//变量ival jval kval不是常量
const unsigned ival = 512, jval = 1024, kval=4096;