#14594: c++


100318 (曹吉百)

School : 臺北市立建國高級中學
ID : 69094
IP address : [210.71.78.244]
Last Login :
2020-11-04 13:56:05
a864. 4. Stellar Classification -- HP CodeWars2010 | From: [203.72.178.252] | Post Date : 2018-07-25 13:44

#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
	char name[100];
	double B,V;
	while(cin>>name, strcmp(name,"END")!=0)
	{
		cin >>B >>V;
		printf("%s %.2lf", name, B-V);
		double d=B-V;
		if     (d <-0.25) printf(" O");
		else if(d < 0.0 ) printf(" B");
		else if(d < 0.25) printf(" A");
		else if(d < 0.5 ) printf(" F");
		else if(d < 1.0 ) printf(" G");
		else if(d < 1.5 ) printf(" K");
		else printf(" M");
		printf("\n");
	}
	return 0;
}
 
ZeroJudge Forum