~cpp
#include<iostream> 
using namespace std; 

void main(){ 

    int i; 
    char a[5] ={0,}; 
    do{ 
    cout << "점수 입력:";  
    cin >> i; 

    if(i==999) continue; 
    else if(i<0 || i>100){
	                 cout << "잘못 했습니다 다시 해주세요" <<endl;  continue; 
					}

    switch(i/10){ 
    case 10: 
    case 9: a[0] +=1; break; 

    case 8: a[1] +=1; break; 

    case 7: a[2] +=1; break; 

    case 6: a[3] +=1; break; 

    default: a[4] +=1; break; 
    
    } 

    }while(!(i==999)); 

    for(i=0;i<4;i++) 
        printf("%c:%d명\n",'A'+i,a[i]); 
    printf("F:%d명\n",a[4]); 
} 
Retrieved from http://wiki.zeropage.org/wiki.php/데블스캠프2006/월요일/연습문제/switch/김준석
last modified 2021-02-07 05:29:04