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(){
	int n,pj,pm,pe;
	while(n){
		cin>>n;
		for(int i<=1;i<=n;i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pj==100||pe==100){
				cout<<"A"<<endl;
			}else if((pm+pe)/2>=90){
				cout<<"A"<<endl;
			}else if((pm+pe+pj)/3>=80){
				cout<<"A"<<endl;
			}else if((pm+pe+pj)/3>=70){
				cout<<"B"<<endl;
			}else if((pm+pe+pj)/3>=50&&pm>=80||pe>=80){
				cout<<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	}
}

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

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

struct edge {
    int to, cost;
};

struct state {
    int v, d, rest;
    bool operator<(const state& s)const{
        return d>s.d;
    }
};

int main(){
    int n;
    while (cin >> n, n){
        int math, eng, jap;
        rep(i, n){
            cin >> math >> eng >> jap;
            if (math == 100 || eng == 100 || jap == 100 ||
                (math + eng) / 2 >= 90 || (math + eng + jap) / 3 >= 80){
                cout << "A" << endl;
            }
            else if ((math + eng + jap) / 3 >= 70 ||
                (math + eng + jap) / 3 >= 50 && (math >= 80 || eng >= 80)){
                cout << "B" << endl;
            }
            else{
                cout << "C" << endl;
            }
        }
    }
}

C++: #include<cstdio>
using namespace std; 

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

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {

    while (true) {
        int n; cin >> n;
        if (n == 0)
            break;
        rep(i, n) {
            int m, e, j; cin >> m >> e >> j;
            if (m == 100 || e == 100 || j == 100) {
                puts("A");
            }
            else if ((m+e)/2 >= 90) {
                puts("A");
            }
            else if ((m+e+j)/3 >= 80) {
                puts("A");
            }
            else if ((m+e+j)/3 >= 70) {
                puts("B");
            }
            else if ((m+e+j)/3 >= 50 && (m >= 80 || e >= 80)) {
                puts("B");
            }
            else {
                puts("C");
            }
        }
    }
}

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 <iostream>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        while (n--) {
            int pm, pe, pj;

            cin >> pm >> pe >> pj;

            if (pm == 100 || pe == 100 || pj == 100) 
                cout << 'A';
            else if ((pm + pe) / 2.0 >= 90) 
                cout << 'A';
            else if ((pm + pe + pj) / 3.0 >= 80)
                cout << 'A';
            else if ((pm + pe + pj) / 3.0 >= 70)
                cout << 'B';
            else if ((pm + pe + pj) / 3.0 >= 50 && (pm >= 80 || pe >= 80))
                cout << 'B';
            else 
                cout << 'C';
            cout << endl;
        }
    }

    return 0;
}

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

int school(int m, int e, int j)
{
if( m == 100 || e == 100 || j == 100 )
        return 'A';
    if( (m+e)>=180 || (m+e+j)>=240)
        return 'A';
    if( (m+e+j)>=210 || ( (m+e+j)>=150 && (m>=80||e>=80) ) )
		return 'B';
	return 'C';
}
int main()
{
	int x, m, e, j;
	while(cin>>x)
	{
		for(int i=0; i<x; i++)
		{
			cin>>m>>e>>j;
			cout<<school(m,e,j);
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int main(){
	int n;
	while(cin >> n){
	int t[3],tt[2];
	string ans[n];
	for(int i = 1;n >= i;i++){
		for(int ii = 1;3 >= ii;ii++){
			cin >> t[1] >> t[2] >> t[3];
			tt[1] = ( t[1] + t[2] ) / 2;
			tt[2] = ( t[1] + t[2] + t[3]) / 3;
			if(t[1] == 100 or t[2] == 100 or t[3] == 100 or  tt[1] >= 90 or t[2] >= 80){
				ans[i] = "A";
			}else if(tt[2] >= 70){
				ans[i] = "B";
			}else if(tt[2] >= 50 and t[1] >= 80 or tt[2] >= 50 and t[2] >= 80){
				ans[i] = "B";
			}else{
				ans[i] = "C";
			}
		}
	}
	for(int iii = 1;n >= iii;iii++){
		cout << ans[iii] << endl;
	}
}

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

int main() {
	int n;
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			int pm, pe, pj;
			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) && (pe >= 80 || pm >= 80))) {
				cout << 'B' << endl;
			}
			else {
				cout<< 'C' << endl;
			}
		}
	}
	return 0;
}

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;
}