본문 바로가기
공부/개발노트

[C/C++] 삼항연산자를 사용한 조건식을 if문으로 바꿔보기

반응형

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
using namespace std;
 
int main(){
    bool largefile;
    unsigned int filesize;
    largefile = filesize >
    1024 * 1024 ? true : false
    
    return 0;
}
cs
[예제 1-1] 삼항 연산자를 활용한 조건식


1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;
 
int main(){
    bool largefile;
    unsigned int filesize;
    if(filesize > 1024 * 1024){
        largefile = true;
    } else {
        largefile = false;
    }
    
    return 0;
}
cs


[예제 1-2] 예제 1-1을 if문으로 바꾼 결과


반응형