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>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[1000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
    int n;
    int a,b,c;
    while(cin>>n,n){
        double ave;
        double mave;
        for(int i=0;i<n;i++){
            cin>>a>>b>>c;    
            ave=(a+b+c)/3;
            mave=(a+b)/2;
            if(a==100||b==100||c==100) cout<<"A"<<endl;
            else if(mave>=90) cout<<"A"<<endl;
            else if(ave>=80) cout<<"A"<<endl;
            else if(ave>=70) cout<<"B"<<endl;
            else if(ave>=50&&(b>=80||a>=80)) cout<<"B"<<endl;
            else cout<<"C"<<endl;
        }
    }
    return 0;
}

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

int main(){
  int n,m,e,j,ave2,ave3;

  while(1){
    cin>>n;
    if(n==0)
      break;
    for(int i=0;i<n;i++){
      cin>>m>>e>>j;
      ave2=m+e;
      ave3=m+e+j;
      if((m==100 || e==100|| j==100) || (ave2 >= 180) || (ave3 >= 240))
        cout<<"A"<<endl;
      else if((ave3 >= 210) || ((ave3>=150) && (m >= 80 || e >= 80)))
        cout<<"B"<<endl;
      else
        cout<<"C"<<endl;
    }
  }
  return 0;
}

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

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 || m+e >= 180 || m+e+j >= 240) cout << 'A' << endl;
            else if (m+e+j >= 210 || (m+e+j >= 150 && (m >= 80 || e >= 80))) cout << 'B' << endl;
            else cout << 'C' << endl;
        }
    }

    return 0;
}

C++: /* 
 * File:   main.cpp
 * Author: freebsd
 *
 * Created on 2014/08/28, 10:07
 */

#include <cstdio>

using namespace std;

int main() {
    while (true) {
        int n = 0, pm = 0, pe = 0, pj = 0;
        int ave = 0, avepe = 0;
        
        scanf("%d", &n);
        
        if(n == 0) break;
        
        for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &pm, &pe, &pj);
        
        avepe = (pm + pe) / 2;
        ave = (pm + pe + pj) / 3;
        
        if(pm == 100 || pe == 100 || pj == 100) printf("A\n");
        else if(avepe >= 90) printf("A\n");
        else if(ave >= 80) printf("A\n");
        else if(ave >= 70) printf("B\n");
        else if(ave >= 50 && (pm >= 80 || pe >= 80)) printf("B\n");
        else printf("C\n");
        }
    }
       
    return 0;
}

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

C++: #include<iostream>
#include<cstdio>
#include <cstring>
#include<map>
#include<string>
#include<stack>
#include <sstream>
#include<vector>
using namespace std;


int main(){
	int n;
	while(cin>>n)
	{
		char ans[10010];
		if(n==0)break;
		for(int i=0; i<n; i++)
		{
			int ei,suu,koku;
			cin>>suu>>ei>>koku;
			if( suu==100 || ei==100 || koku==100 ) ans[i]=*"A";
			else if( (suu+ei)/2 >= 90 ) ans[i]=*"A";
			else if( (suu+ei+koku)/3 >=80 ) ans[i]=*"A";
			else if( (suu+ei+koku)/3 >=70 ) ans[i]=*"B";
			else if( (suu+ei+koku)/3 >=50  && (suu==80 || ei==80 ) ) ans[i]=*"B";
			else ans[i]=*"C";
		}
		for(int i=0; i<n; i++) cout<<ans[i]<<endl;
	}
	return 0;
}

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

int middium(int mat,int ing, int jap){
	return (mat + ing + jap) / 3;
}


void classes(int mat,int ing,int jap){
	int mid;
	mid = middium(mat,ing,jap);

	if(mat == 100 || ing == 100 || jap == 100) cout <<  "A";
	else if((mat + ing)/2 >= 90)	cout << "A";
	else if(mid >= 80)	cout <<  "B";
	else if(mid	>= 70)	cout <<  "B";
	else if(mid >= 50 && (mat >= 80 || ing >= 80))	cout <<  "B";
	else	cout << "C";
}

int main(){
	int n,pm,pe,pj;
	char cla;

	while(cin >> n,n){
		for(int i=0;i<n;i++){
			cin >> pm >> pe >> pj;
			classes(pm,pe,pj);
			cout << endl;
		}
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-8;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		while (n--)
		{
			int m, e, j;
			scanf("%d%d%d", &m, &e, &j);
			int ave = (m + e + j) / 3;
			int r = 0;
			if (m == 100 || e == 100 || j == 100
				|| (m + e) / 2 >= 90
				|| ave >= 80)
				r = 2;
			else if (ave >= 70
				|| ave >= 50 && (m >= 80 || e >= 80))
				r = 1;

			printf("%c\n", r == 0 ? 'C' : (r == 1 ? 'B' : 'A'));
		}
	}

	return 0;
}

C++: #include <iostream>

char jukuClass(int, int, int);

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

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