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>
int main(void)
{
    int n,pm,pe,pj,i,s,d;
	scanf("%d",&n);
	for (i=0;i<n;i++){
	    scanf("%d %d %d",&pm,&pe,&pj);
		s=(pm+pe)/2.0;
		d=(pm+pe+pj)/3.0;
		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>
#define EPS 1e-10

using namespace std;


int main(){
  int n,A,B,C;
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> A >> B >> C;
      if(A == 100 || B == 100 || C == 100)cout << "A" << endl;
      else if((A+B) >= 160)cout << "A" << endl;
      else if((A+B+C) >= 240)cout << "B" << endl;
      else if((A+B+C)>=150 && (A>=80 || B>=80))cout << "B" << endl;
      else cout << "C" << endl;
    }
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    int p,d,d2;
    for(int i=0;i<n;i++){
      cin>>p>>d>>d2;
      if(p==100||d==100||d2==100){
	cout<<'A'<<endl;
      }else if((p+d)/2>=90){
	cout<<'A'<<endl;
      }else if((p+d+d2)/3>=80){
	cout<<'A'<<endl;
      }else if((p+d+d2)/3>=70){
	cout<<'B'<<endl;
      }else if((p+d+d2)/3>=50&&(p>=80||d>=80)){
	cout<<'B'<<endl;
      }else{
	cout<<'C'<<endl;
      }
    }
  }
  return(0);
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        for (int i = 0; i < n; ++i) {
            int a, b, c;
            cin >> a >> b >> c;
            if(max({a, b, c}) == 100) puts("A");
            else if(a+b >= 180) puts("A");
            else if(a+b+c >= 240) puts("A");
            else if(a+b+c >= 210) puts("B");
            else if(a+b+c >= 150 && max(a, b) >= 80) puts("B");
            else puts("C");
        }
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, c;
	for (int h = 0; h < 1000; h++) {
		cin >> n;
		if (n == 0) {
			cin >> n; return 0;
		}
		for (int i = 0; i < n; i++) {
			cin >> a >> 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 || b >= 80)) {
				cout << 'B' << endl;
			}
			else {
				cout << 'C' << endl;
			}
		}
	}
	cin >> n;
}

C++: #include <iostream>
char whichClass(int math, int eng, int jpn)
{
    if (math == 100 || eng == 100 || jpn == 100) {
        return 'A';
    }
    if (math + eng >= 180) {
        return 'A';
    }
    int sum = math + eng + jpn;
    if (sum >= 240) {
        return 'A';
    }
    if (sum >= 210) {
        return 'B';
    }
    if (sum >= 150 && (math >= 80 || eng >= 80)) {
        return 'B';
    }
    return 'C';
}

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

C++: #include <iostream>
using namespace std;
int main(void){
    int n, m, e, j;
    while(cin >> n && n){
        for(int i = 0; i < n; i++){
            cin >> m >> e >> j;
            if(m==100 || e==100 || j ==100){
                cout << "A" << endl;
            }else if(m +e >= 180 ){
                cout << "A" << endl;
            }else if(m + e + j >= 240){
                cout << "A" << endl;
            }else if(m + e + j >= 210){
                cout << "B" << endl;
            }else if(m + e + j >= 150 && (m >=80 || e >= 80)){
                cout << "B" << endl;
            }else{
                cout << "C" << endl;
            }
        }
    }
}

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

C++: //============================================================================
// Name        : AOJ.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <cctype>
using namespace std;

int main() {
	int n,m,e,j;
	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin>>m>>e>>j;
			if(m==100 || e==100 || j==100)cout<<"A"<<endl;
			else if((m+e)/2>=90)cout<<"A"<<endl;
			else if((m+e+j)/3>=80)cout<<"A"<<endl;
			else if((m+e+j)/3>=70)cout<<"B"<<endl;
			else if(((m+e+j)/3>=50&&m>=80)||((m+e+j)/3>=50&&e>=80))cout<<"B"<<endl;
			else cout<<"C"<<endl;
		}
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	int pm,pe,pj,n;

	while( cin >> n && n != 0 ){
		for( int i = 0;i < n;i++ ){
			cin >> pm >> pe >> pj;

			if( pm == 100 || pe == 100 || pj == 100 || ( 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;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,a1,a2,a3,i,sum=0,avg=0;
	while(1){
		cin>>a;
		if(a==0) break;
		for(i=0;i<a;i++){
			cin>>a1>>a2>>a3;
			sum=a1+a2+a3;
			avg=sum/3;
			if(a1==100||a2==100||a3==100||avg>=80||(a1+a2)/2>=90)
				printf("A\n");
			else if(avg>=70||
				avg>=50&&a1>=80||
				avg>=50&&a2>=80)
				printf("B\n");
			else
				printf("C\n");
		}
	}
	return 0;
}