Algorithm/goorm

goorm 공백 없애기, 계산기, 삼각형의 넓이

마띠(쥔장) 2020. 8. 19. 00:55

#include <iostream>
#include <string>

using namespace std;
int main(void) {
	string str;
	getline(cin, str);
	for (int i = 0; i < str.length(); ++i){
		if (str[i] != ' ')
			cout << str[i];
	}
	
	
	return 0;
}

 

#include <iostream>
#include <iomanip>
using namespace std;
int main(void) {
	int n1, n2 = 0;
	char c = ' ';
	cin >> n1 >> c >> n2;
	switch(c){
		case '+':
			cout<<n1+n2;
			break;
		case '-':
			cout<<n1-n2;
			break;
		case '*':
			cout<<n1*n2;
			break;
		case '/':
			cout<<fixed<<setprecision(2);
			cout<<(double(n1)/double(n2));
			break;
			
		return 0;
	}
	
}

 

#include <iostream>
#include <iomanip>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b; // 밑변, 높이
	cout<<fixed<<setprecision(2);
	cout.precision(1);
	cout << a*b/2.0;
	
	return 0;
}
728x90