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 <bits/stdc++.h>
using namespace std;

int main(void) {
    int n,pm,pe,pj;
    while (cin>>n) {
        if (n==0) {
            break;
        } else {
            for (int i=0;i<n;i++) {
                cin>>pm>>pe>>pj;
                if (pm==100||pe==100||pj==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<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) ans[i]++;
                if((a + b + c) / 3 >= 50 && a >= 80) ans[i]++;
                if((a + b + c) / 3 >= 50 && b >= 80) ans[i]++;
            }
        }
       for(i = 0; i < n; i++){
            if(ans > 1) printf("%s\n", 'A');
            if(ans == 1) printf("%s\n", 'B');
            if(ans == 0) printf("%s\n", 'C');
       }
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n == 0) break;

    int ja,ma,en;
    for(int i = 0;i < n;i++){
      cin >> ma >> en >> ja;
      if(ja == 100 || ma == 100 || en == 100){
        cout << 'A' << endl;
      }else if((ma + en)/2 >= 90){
        cout << 'A' << endl;
      }else{
        double ave;
        ave = (ja + ma + en)/3.0;
        if(ave >= 80){
          cout << 'A' << endl;
        }else if(ave >= 70 || (ave >= 50 && (ma >= 80 || en >= 80))){
          cout << 'B' << endl;
        }else{
          cout << 'C' << endl;
        }
      }
    }
  }

  return 0;
}

C++: #include<iostream>
using namespace std;
int main(void){
    int n,pm,pe,pj;
    while(cin >> n){
        for(int i=0; i<n; i++){
            cin >> pm >> pe >> pj;
            if(pm==100 || pe==100 || pj ==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++: // 2011/07/05 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			if(pm==100||pe==100||pj==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;
		}
	}

	return 0;
}

C++: #include <stdio.h>

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

C++: #include<iostream>

int n,pm,pe,pj;

char solve(int m, int e, int j){
	char ans='C';
	if(m==100 || e==100 || j==100 || m+e>=180 || m+e+j>=240)
		ans = 'A';
	else if(m+e+j>=210 || (m+e+j>=50 && (m>=80 || e>=80)))
		ans = 'B';
	return ans;
}

int main(){
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		for(int i=0; i<n; i++){
			std::cin >> pm >> pe >> pj;
			std::cout << solve(pm, pe, pj);
		}
		delete[] c;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <stack>
#include <list>

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,b,n) for(int i=b;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

const float PI = 3.1415926;
static const int INFTY = (1<<30);

using namespace std;

typedef long long ll;
typedef long double ld;

int n;

int main() {
  while(cin >> n, n) {
    rep(i, n) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      float tmp1 = (pm + pe) / 2.0;
      float tmp2 = (pm + pe + pj) / 3.0;
      if(tmp1 > 90 || tmp2 > 80 || pm == 100 || pe == 100 || pj == 100) {
        cout << 'A' << endl;
      } else if (tmp2 > 70 || (tmp2 > 50 && (pm > 80 || pe > 80))) {
        cout << 'B' << endl;
      } else {
        cout << 'C' << endl;
      }
    }
  }
  return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int main()
{
	while(1)
	{
		int n;
		cin >> n;
		if(n == 0) return 0;
		for(int i=0;i<n;i++)
		{
			int a,b,c;
			cin >> a >> b >> c;
			if(a == 100 || b == 100 || c == 100 || a+b >= 180 || a+b+c >= 240)
			{
				puts("A");
			}
			else if(a+b+c >= 210 || (a+b+c >= 150 && (a >= 80 || b >= 80)))
			{
				puts("B");
			}
			else
			{
				puts("C");
			}
		}
	}
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int main() {
  
  int N;
  while(cin >> N && N) {
    for(int i=0; i<N; i++) {
      double a, b, c;
      cin >> a >> b >> c;
      string r;
      if(a == 100.0 || b == 100.0 || c == 100.0) r = "A";
      else if((a+b)/2 >= 90.0) r = "A";
      else if((a+b+c)/3 >= 80.0) r = "A";
      else if((a+b+c)/3 >= 70.0) r = "B";
      else if((a+b+c)/3 >= 50.0 && (a >= 80.0 || b >= 80.0)) r = "B";
      else r = "C";
      cout << r << endl;
    }
  }
  
  return 0;
}