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<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,i,m,e,j;
	char s[10001];
	while(1){
		cin>>n;
		if(n==0) break;
		for(i=0;i<n;i++){
			cin>>m>>e>>j;
			if(m==100||e==100||j==100||(m+e)/2>=90||(m+e+j)/3>=80) s[i]='A';
			else if((m+e+j)/3>=70||((m+e+j)/3>=50&&(m>=80||e>=80))) s[i]='B';
			else s[i]='C';
		}
		for(i=0;i<n;i++) cout<<s[i]<<endl;
	}
	return 0;
}

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

int main()
{
  int n;
  while (cin >> n && n != 0){
    while (n--){
      int a, b, c;
      cin >> a >> b >> c;
      if (a == 100 || b == 100 || c == 100){
        cout << 'A' << endl;
        continue;
      }
      if (a + b >= 180){
        cout << 'A' << endl;
        continue;
      }
      if (a + b + c >= 240){
        cout << 'A' << endl;
      }
      if (a + b + c >= 210){
        cout << 'B' << endl;
        continue;
      }
      if (a + b + c >= 150 && (a >= 80 || b >= 80)){
        cout << 'B' << endl;
        continue;
      }
      cout << 'C' << endl;
    }
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	while(true){
	cin>>n;
	if(n==0)return 0;
	for(int pm,pe,pj;n>=1;n--){
		cin>>pm>>pe>>pj;
		if(pm==100||pe==100||pj==100)cout<<"A\n";
		else if(pm+pe>=180)cout<<"A\n";
		else if(pm+pe+pj>=240)cout<<"A\n";
		else if(pm+pe+pj>=210)cout<<"B\n";
		else if(pm+pe+pj>=150&&pm>=80||pe>=80)cout<<"B\n";
		else cout<<"C\n";
	}
	}
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
class data{
public:
    int pm,pe,pj,rank;
    double me(){return (double)(pm+pe)/2;};
    double ave(){return (double)(pm+pe+pj)/3;}
    int maxi(){return max(max(pm,pe),pj);};
};
int main(){
    int n;
    while(cin>>n,n){
        vector<data>v(n+1);
        rep(i,n+1){
            v.clear();
            cin>>v[i].pm>>v[i].pe>>v[i].pj;
            if(v[i].me()>=90||v[i].ave()>=80||v[i].maxi()==100){
                v[i].rank=3;
            }else if(v[i].ave()>=70||(v[i].ave()>=50&&(v[i].pe>=80||v[i].pm>=80)))
                v[i].rank=2;
            else
                v[i].rank=1;
            switch (v[i].rank) {
                case 1:
                    cout<<"C"<<endl;
                    break;
                case 2:
                    cout<<"B"<<endl;
                    break;
                default:
                    cout<<"A"<<endl;
                    break;
            }
        }
    }
    
}

C++: #include <iostream>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		for(int i = 0; i < n; ++i)
		{
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			if(pm == 100 || pe == 100 || pj == 100 || (pm + pe >= 180) || (pm + pe + pj >= 240))
			{
				cout << "A" << endl;
			}
			else if((pm + pe + pj >= 210) || (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)))
			{
				cout << "B" << endl;
			}
			else
			{
				cout << "C" << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: /*100 点の科目がある 	A
数学と英語の平均点が 90 点以上 	A
3 科目の平均点が 80 点以上 	A
3 科目の平均点が 70 点以上 	B
3 科目の平均点が 50 点以上で数学か英語が 80 点以上 	B
上の条件を満たさない 	C*/
#include<iostream>
using namespace std;
int main(){
	for(;;){
		int n;
		cin>>n;
		for(int i=0;i<n;i++){
			int a,b,c;
			cin>>a;
			if(a==0)break;
			cin>>b>>c;
			if(a==100||b==100||c==100){
				cout<<"A"<<endl;
			}	
			else if((a+b)/2>=90){
				cout<<"A"<<endl;
			}
			else if((a+b+c)/3>=80){
				cout<<"A"<<endl;
			}
			else if((a+b+c)/3>=70){
				cout<<"B"<<endl;
			}
			else if((a+b+c)/3>=50&&a>=80){
				cout<<"B"<<endl;
			}	
			else if((a+b+c)/3>=50&&b>=80){
				cout<<"B"<<endl;
			}
			else{
				cout<<"C"<<endl;
			}
		}
	}
}

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

char classify(int m, int e, int j){
    if(m == 100 || e == 100 || j == 100)    return 'A';
    if((m+e)/2 >= 90)   return 'A';
    if((m+e+j)/3 >= 80) return 'A';
    if((m+e+j)/3 >= 70)    return 'B';
    if((m+e+j)/3 >= 50 && max(m,e) >= 80)   return 'B';
    return 'C';
}

int main(){
    int n;
    while(cin >> n, n){
        int m, e, j;
        for(int i = 0; i < n; i++){
            cin >> m >> e >> j;
            cout << classify(m,e,j) << endl;
        }
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,pj,pm,pe;
	while(1){
		cin>>n;
		if(n==0) break;
		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/3+pe/3+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>

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 >= 80 || b >= 80)){
        printf("B\n");
    }else{
        printf("C\n");
    }
}

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

int main(){
	
	int n;
	while(cin>>n){
		if(n!=0){
	while(n>0){
		int pm,pe,pj;
		cin>>pm>>pe>>pj;
		if(pm>=90||(pm+pe)/2>=90||(pm+pe+pj)/3>=80)
			cout<<"A"<<endl;
		else if((pm+pe+pj)/3>=70||((pm+pe+pj)/3>=50&&pm>=80||pe>=80))
			cout<<"B"<<endl;
		else
			cout<<"C"<<endl;
		n--;
	}
	}
		else
			break;
	}

	

}

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