์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ/BOJ_Cpp

[BOJ/Step2] if๋ฌธ (C++)

NaNaRin๐Ÿ™ƒ 2021. 9. 15. 15:44

https://www.acmicpc.net/problem/1330 : ๋‘ ์ˆ˜ ๋น„๊ตํ•˜๊ธฐ

c++
๋‹ซ๊ธฐ
#include <iostream> using namespace std; int main(void){ โ€‹โ€‹โ€‹โ€‹int a, b; โ€‹โ€‹โ€‹โ€‹cin >> a >> b; โ€‹โ€‹โ€‹โ€‹if(a > b){ โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹cout << ">" << endl; โ€‹โ€‹โ€‹โ€‹} else if (a < b){ โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹cout << "<" << endl; โ€‹โ€‹โ€‹โ€‹}else{ โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹cout << "==" << endl; โ€‹โ€‹โ€‹โ€‹} โ€‹โ€‹โ€‹โ€‹ }

 

https://www.acmicpc.net/problem/9498 : ์‹œํ—˜ ์„ฑ์ 

c++
๋‹ซ๊ธฐ
#include <iostream> using namespace std; int main(void){ โ€‹โ€‹โ€‹โ€‹int score; โ€‹โ€‹โ€‹โ€‹cin >> score; โ€‹โ€‹โ€‹โ€‹if(score >= 90) cout << "A" << endl; โ€‹โ€‹โ€‹โ€‹else if(score >= 80) cout << "B" << endl; โ€‹โ€‹โ€‹โ€‹else if(score >= 70) cout << "C" << endl; โ€‹โ€‹โ€‹โ€‹else if(score >= 60) cout << "D" << endl; โ€‹โ€‹โ€‹โ€‹else cout << "F" << endl; }

 

https://www.acmicpc.net/problem/2753 : ์œค๋…„

c++
๋‹ซ๊ธฐ
#include <iostream> using namespace std; int main(void){ โ€‹โ€‹โ€‹โ€‹int year; โ€‹โ€‹โ€‹โ€‹cin >> year; โ€‹โ€‹โ€‹โ€‹if((year%4==0 && year%100!=0) || year%400==0 ) cout << 1 << endl; โ€‹โ€‹โ€‹โ€‹else cout << 0 << endl; }

 

https://www.acmicpc.net/problem/14681 : ์‚ฌ๋ถ„๋ฉด ๊ณ ๋ฅด๊ธฐ

c++
๋‹ซ๊ธฐ
#include <iostream> using namespace std; int main(void){ โ€‹โ€‹โ€‹โ€‹int x, y; โ€‹โ€‹โ€‹โ€‹cin >> x >> y; โ€‹โ€‹โ€‹โ€‹if(x>0 && y >0) cout << 1 << endl; โ€‹โ€‹โ€‹โ€‹else if(x>0 && y<0) cout << 4 << endl; โ€‹โ€‹โ€‹โ€‹else if(x<0 && y>0) cout << 2 << endl; โ€‹โ€‹โ€‹โ€‹else if(x<0 && y<0) cout << 3 << endl; }

 

https://www.acmicpc.net/problem/2884 : ์•Œ๋žŒ ์‹œ๊ณ„

c++
๋‹ซ๊ธฐ
#include <iostream> using namespace std; int main(void){ โ€‹โ€‹โ€‹โ€‹int h, m; โ€‹โ€‹โ€‹โ€‹cin >> h >> m; โ€‹โ€‹โ€‹โ€‹m -= 45; โ€‹โ€‹โ€‹โ€‹if(m < 0) h -= 1, m += 60; โ€‹โ€‹โ€‹โ€‹if(h < 0) h =23; โ€‹โ€‹โ€‹โ€‹cout << h << " " << m << endl; }