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 <iostream>
using namespace std;

int main(void){
	int n,a,b,c; //ツ青板学,ツ英ツ古ェ,ツ債堕古ェ

	while(cin>>n && n){
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;

			double me = (a + b) / 2.0;
			double avg = (a + b + c) / 3.0;

			if(a==100 || b==100 || c==100 || me >= 90 || avg >= 80)
				cout<<"A\n";
			else if(avg >= 70 || avg >= 50 && (a >= 80 || b >= 80))
				cout<<"B\n";
			else
				cout<<"C\n";
		}
	}

	return 0;
}

C++: #include <iostream>

using namespace std;
 
void res(int, int, int);
 
int main()
{
    int n, pm, pe, pj;
 
    while (cin >> n, n) {
	for (int i = 0; i < n; i++) {
	    cin >> pm >> pe >> pj;
	    res(pm, pe, pj);
	}
    }
    return 0;
}
 
void res(int pm, int pe, int pj)
{
    double ave, meave;
 
    ave = (double)(pm + pe + pj) / 3;
    meave = (double)(pm + pe) / 2;
 
    if (pm == 100 || pe == 100 || pj == 100 || meave >= 90 || ave >= 80) {
	cout << 'A' << endl;
    } else if (ave >= 70 || ( ave >= 50 && ( pm >= 80 || pe >= 80))) {
	cout << 'B' << endl;
    } else {
        cout << 'C' << endl;
    }
}

C++: #include <stdio.h>
int main(){
	int i,n,pm,pj,pe;
	double avg,emav;
	char type;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d%d%d",&pm,&pe,&pj);
			avg = (pm+pe+pj) / 3.0;
			emav = (pm+pe) / 2.0;
			if(pm==100.0||pe==100.0||pj==100.0||emav>=90.0||avg>=80.0) type = 'A';
			else if(avg>=70.0) type = 'B';
			else if(avg>=50.0&&(pe>=80.0||pm>=80.0)) type = 'B';
			else type = 'C';
		}
		printf("%c\n",type);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <stdio.h>

float mean2(int x, int y)
{
    return (float)(x + y) / 2.0;
}

float mean3(int x, int y, int z)
{
    return (floag)(x + y + z) / 3.0;
}

char grading(int p_math, int p_eng, int p_jpn)
{
    if ( p_math == 100 || p_eng == 100 || p_jpn == 100) {
        return 'A';
    } else if (mean2(p_math, p_jpn) >= 90.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 80.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0) {
        return 'B'
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0 && (p_math >= 80 || p_eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    int i, p_math, p_eng, p_jpn, n_iteration;
    char grade;

    scanf("%d", &n_iteration);

    for (i = 0; i < n_iteration; i++) {
        scanf("%d %d %d", &p_math, &p_eng, &p_jpn);
        grade = grading(p_math, p_eng, p_jpn);
        printf("%c\n", grade);
    }
    return 0;
}

C++: #include <stdio.h>

char judge(int pm, int pe, int pj)
{
    int average = (pm + pe + pj) / 3;
    if (pm == 100 || pe == 100 || pj == 100) {
        return 'A';
    } else if ((pm + pe) / 2 >= 90) {
        return 'A';
    } else if (average >= 80) {
        return 'A';
    } else if (average >= 70) {
        return 'B';
    } else if (average >= 50 && (pm >= 80 || pe >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    int n, pm, pe, pj;
    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; i++) {
           scanf("%d %d %d",&pm, &pe, &pj);
            printf("%c", judge(pm, pe, pj));
        }
    }
    return 0;
}

C++: #include <iostream>

char aizu(int pm, int pe, int pj)
{
    if (pm==100 || pm==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';
    }
}

int main()
{
    int n,pm,pe,pj;
    while(1){
        std::cin >> n;
        if(n==0){
            break;
        }
        for (int i=0; i<n; i++) {
            std::cin >> pm >> pe >> pj;
            std::cout << aizu(pm, pe, pj) << std::endl;
        }
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	int m[100] = {};
	int e[100] = {};
	int j[100] = {};
	char* rank[10000] = {};
	while (cin >> n) {
		for (int i = 0; i < n; i++) {
			cin >> m[i] >> e[i] >> j[i];
		}
		for (int i = 0; i < n; i++) {
			int s = (m[i] + e[i] + j[i]) / 3;
			if ((m[i] || e[i] || j[i]) == 100) {
				rank[i] = "A";
			}
			else if ((m[i] + e[i]) / 2 >= 90) {
				rank[i] = "A";
			}
			else if (s >= 80) {
				rank[i] = "A";
			}
			else if (s >= 70) {
				rank[i] = "B";
			}
			else if (s >= 50 && m[i] >= 80) {
				rank[i] = "B";
			}
			else {
				rank[i] = "C";
			}
			cout << rank[i] << endl;
		}
	}


	return 0;
	
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, a, b, c;
	vector<char>l;
	while (true){
		cin >> n;
		if (n == 0){
			break;
		}
		else{
			for (int i = 0; i < n; i++){
				cin >> a >> b >> c;
				if (a == 100 || b == 100 || c || 100){
					l.push_back('A');
				}
				else if (a + b >= 180){
					l.push_back('A');
				}
				else if (a + b + c >= 240){
					l.push_back('A');
				}
				else if (a + b + c >= 210){
					l.push_back('B');
				}
				else if (a + b + c >= 150 && a >= 80){
					l.push_back('B');
				}
				else if (a + b + c >= 150 && b >= 80){
					l.push_back('B');
				}
				else l.push_back('C');
			}
		}
	}
	for (int i = 0; i != l.size(); i++)
	{
		cout << l[i] << endl;
	}
}

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

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

#define rep(i,n) for(int i=0;i<n;i++)
#define clear(v) memset(v,0,sizeof(v))
#define ALL(v) (v).begin(),(v).end()


int main(){
	int n;
	while (cin >> n, n){
		rep(i, n){
			int p[3]; rep(i, 3) cin >> p[i];
			double ave = (p[0] + p[1] + p[2]) / 3.0;
			char ans;
			if (p[0] == 100 || p[1] == 100 || p[2] == 100){
				ans = 'A';
			} else if ((p[0]+p[1])/2.0>=90){
				ans = 'A';
			} else if (ave >= 80){
				ans = 'A';
			} else if (ave >= 70){
				ans = 'B';
			} else if (ave >= 50 && (p[0] >= 80 || p[1] >= 80)){
				ans = 'B';
			} else{
				ans = 'C';
			}
			cout << ans << endl;
		}
	}
}

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

char judge(int pm, int pe, int pj){
    if ( pm == 100 || pe == 100 || pj == 100 ) return 'A';
    if ( (pm + pe)/2 >= 90 ) return 'A';
    if ( (pm + pe + pj)/3 >= 80 ) return 'A';
    if ( (pm + pe + pj)/3 >= 70 ) return 'B';
    if ( (pm + pe + pj)/3 >= 50 ){
	if ( pm >= 80 || pe >= 80 ) return 'B';
    }
    return 'C';
}

main(){
    int n, pm, pe, pj;
    while(1){
	cin >> n;
	if ( n == 0 ) break;
	assert(1 <= n && n <= 10000);
	for ( int i = 0; i < n; i++ ){
	    cin >> pm >> pe >> pj;
	    assert( 0 <= pm && pm <= 100);
	    assert( 0 <= pe && pe <= 100);
	    assert( 0 <= pj && pj <= 100);
	    cout << judge(pm, pe, pj) << endl;
	}
    }
}