Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			math, _ := strconv.Atoi(buf[0])
			english, _ := strconv.Atoi(buf[1])
			japanese, _ := strconv.Atoi(buf[2])
			if math == 100 || english == 100 || japanese == 100 {
				fmt.Println("A")
			} else if math + english >= 180 {
				fmt.Println("A")
			} else if math + english + japanese >= 240 {
				fmt.Println("A")
			} else if math + english + japanese >= 210 {
				fmt.Println("B")
			} else if math + english + japanese >= 150 && (math >= 80 || english >= 80) {
				fmt.Println("B")
			} else {
				fmt.Println("C")
			}
		}
	}
}

C++: #include <stdio.h>
#include <stdbool.h>

char dividing(int pm, int pe, int pj);

int main(void)
{
	int ninnzuu;
	int pm[1000], pe[1000], pj[1000];
	char class[1000];
	while(true) {
		scanf("%d", &ninnzuu);
		if(ninnzuu == 0) {
			break;
		}
		for(int i = 0; i < ninnzuu; i++) {
			scanf("%d %d %d", &pm[i], &pe[i], &pj[i]);
			class[i] = dividing(pm[i], pe[i], pj[i]);
		}
		for(int i = 0; i < ninnzuu; i++) {
			printf("%c\n", class[i]);
		}
	}
	return 0;
}

char dividing(int pm, int pe, int pj)
{
	if(pm == 100 || pe == 100 || pj == 100) {
		return 'A';
	}else 	if(pm + pe >= 180) {
		return 'A';
	}else 	if(pm + pe + pj >= 240) {
		return 'A';
	}else  	if(pm + pe + pj >= 210) {
		return 'B';
	}else  	if(pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)) {
		return 'B';
	}else{
		return 'C';
	}
}

C++: #include <stdio.h>
int pa(void)
{
    printf("A\n");
}

int pb(void)
{
    printf("B\n");
}

int pc(void)
{
    printf("C\n");
}

int main(void)
{
    int n, i,sum, pm[10000], pj[10000], pe[10000];
    while(1) {
	scanf("%d", &n);
	if (n == 0) {
	    break;
	}
	sum = pm[i] + pe[i] + pj[i];
	for (i = 0; i < n; i++) {
	    scanf("%d %d %d", &pm[i], &pj[i], &pe[i]);
	    sum = pm[i] + pe[i] + pj[i];
	    if (pm[i] == 100 || pj[i] == 100 || pe[i] == 100) {
		pa();
	    } else if (pm[i] + pe[i] >= 90) {
		pa();
	    } else if (sum >= 240) {
		pa();
	    } else if (sum >= 210) {
		pb();
	    } else if (sum >= 150 && (pm[i] >= 80 || pe[i] >= 80)) {
		pb();
	    } else {
		pc();
	    }
	}
    }
    return 0;
}

C++: #include <stdio.h>
void classchecker(int m,int e,int j);
int main(void){
    int loop,pm,pe,pj;
    while(1)
    {
        scanf("%d", &loop);
        if(loop == 0)
        {
            break;
        }
        for(int i=0;i<loop;i++){
            scanf("%d %d %d", &pm , &pe, &pj);
            classchecker(pm,pe,pj);
        }
    }

    return 0;
}
void classchecker (int m, int e, int j)
{
    if (m == 100 || e == 100 || j == 100)
    {
        printf("A\n");
    } else if (m + e >= 180)
    {
        printf("A\n");
    } else if (m + e + j >= 240)
    {
        printf("A\n");
    } else if (m + e + j >= 210)
    {
        printf("B\n");
    } else if (m + e + j >= 150 && (m >= 80 || e >= 80))
    {
        printf("B\n");
    }else {
        printf("C\n");
    }
    return;
}

C++: #include<stdio.h>
int main(void)
{
    int n,i,a,b,c,w[10000];
	while(1){
	    scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
		    scanf("%d %d %d",&a,&b,&c);
			if(a==100||b==100||c==100||(a+b)/2>=90||(a+b+c)/3>=80) w[i]=1;
			else if((a+b+c)/3>=70||(a+b+c)/3>=50&&(a>=80||b>=80)) w[i]=2;
			else w[i]=3;
		}
		for(i=0;i<n;i++){
		    if(w[i]==1) printf("A\n");
		    if(w[i]==2) printf("B\n");
		    if(w[i]==3) printf("C\n");
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
	for(int i=0;i<n;i++){
		int a,b,c;
		bool f1=0,f2=0;
		cin>>a>>b>>c;
		if(a==100||b==100||c==100)f1=1;
		if((a+b)/2>=90)f1=1;
		if((a+b+c)/3>=80)f1=1;
		if((a+b+c)/3>=70)f2=1;
		if((a+b+c)/3>=50&&a>=80||b>=80)f2=1;
		if(f1==1)cout<<"A";
		else if(f2==1)cout<<"B";
		else if(f1==0&&f2==0) cout<<"C";
		cout<<endl;
		}
	}
}

C++: #include<stdio.h>
int main(void)
{
	int n,a,b,c,i;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);
			if(a==100 || b==100 || c==100 || (a+b)/2>89 || (a+b+c)/3>79)  printf("A\n");
			else if((a+b+c)/3>69 && (a+b+c)/3>49 && (a>79 || b>79))  printf("A\n");
			else if((a+b+c)/3>69 || (a+b+c)/3>49 && (a>79 || b>79))  printf("B\n");
			else printf("C\n");
		}
		scanf("%d",&n);
	}
	return 0;

C++: #include<iostream>
#include<algorithm>
using namespace std;

char classifier(int pm,int pe,int pj){
	if(pm==100||pe==100||pj==100)return 'A';
	if(90<=(pm+pe)/2)return 'A';
	if(80<=(pm+pe+pj)/3)return 'A';
	if(70<=(pm+pe+pj)/3)return 'B';
	if(50<=(pm+pe+pj)/3 && (80<=pm||80<=pe))return 'B';
	return 'C';
}
int main(){
	int n;
	while(cin>>n&&n){
		int a,b,c;
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			cout<<classifier(a,b,c)<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
    while(1)
    {
        int n;
        cin>>n;if(!n)return 0;
        int pm[10000],pe[10000],pj[10000],sc[10000]={0};
        for(int i=0;i<n;++i){
            cin>>pm[i]>>pe[i]>>pj[i];
        	if((pm[i]+pe[i]+pj[i])/3>=50&(pm[i]>=80|pe[i]>=80))
                sc[i]=1;
            if((pm[i]+pe[i]+pj[i])/3>=70)
                sc[i]=1;
            if((pm[i]+pe[i]+pj[i])/3>=80)
                sc[i]=2;
            if((pm[i]+pe[i])/2>=90)
                sc[i]=2;
            if(pm[i]==100|pe[i]==100|pj[i]==100)
                sc[i]=2;
            if(!sc[i])cout<<'C'<<endl;
            if(sc[i]==1)cout<<'B'<<endl;
            if(sc[i]==2)cout<<'A'<<endl;
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	while(cin >> n){
		int mat, eng, jap;
		rep(i, n){
			cin >> mat >> eng >> jap;
			int sum = mat + eng + jap;
			if(mat == 100 || eng == 100 || jap == 100 || sum >= 240 || sum-jap >= 180){
				cout << "A" << endl;
				continue;
			}else if(sum >= 210||(sum >= 150 && (mat >= 80 || eng >= 80))){
				cout << "B" << endl;
				continue;
			}else{
				cout << "C" << endl;
			}
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include<stdio.h>

void dividing_student(int a, int b, int c);

int main(void)
{
    while(1){
        int n;/*nはデータの個数*/
        scanf("%d", &n);    
        if(n == 0){
            break;
        }else{
            for( int i = 0; i < n; ++i){
                int pm ,pe, pj; /*左から数学、英語、国語の点数*/
                scanf("%d %d %d", &pm, &pe, &pj);
                dividing_student( pm, pe, pj);
            }
        }
    }
    return 0;
}

void dividing_student( int a, int b, int c)
{
    if( a >= 100|| b >= 100 || c >=100){
        printf("A\n");
    }else if( (a + b) / 2 >= 90){
        printf("A\n");
    }else if( (a + b + c) / 3 >= 80){
        printf("A\n");
    }else if( (a + b + c) / 3 >= 70){
        printf("B\n");
    }else if((a + b + c) / 3 >= 50 && (a >= 50 || b >= 50)){
        printf("B\n");
    }else{
        printf("C\n");
    }
}