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

using namespace std;

int main() {
	int n;
	int pm,pe,pj;
	double ave,meave;
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		} else {
			for (int i = 0; i < n; i++) {
				cin >> pm >> pe >> pj;
				ave = ((double)pm + (double)pe + (double)pj) / 3.0;
				meave = ((double)pm + (double)pe) / 2.0;
				if (pm == 100 || pe == 100 || pj == 100) {
					cout << "A" << endl;
				} else if (meave >= 90.0) {
					cout << "A" << endl;
				} else if (ave >= 80.0) {
					cout << "A" << endl;
				} else if (ave >= 70.0) {
					cout << "B" << endl;
				} else if (ave >= 50.0 && (pm >= 80.0 || pe >= 80.0)) {
					cout << "B" << endl;
				} else {
					cout << "C" << endl;
				}
			}
		}
	}
	return 0;
}

C++: #define scanf_s scanf
#include <stdio.h>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100000

int main()
{
	while (1) {
		int n, pm, pe, pj, sum;
		scanf_s("%d", &n);
		if (n == 0)break;
		for (int i = 0; i < n; ++i) {
			scanf_s("%d %d %d", &pm, &pe, &pj);
			sum = pm + pe + pj;
			if ((pm == 100 || pe == 100) || pj == 100) printf("A\n");
			else if(pm + pe >= 180) printf("A\n");
			else if (sum >= 240) printf("A\n");
			else if (sum >= 210) printf("B\n");
			else if (sum >= 150 && (pm >= 80 || pe >= 80 )) printf("B\n");
			else printf("C\n");
		}
	}
}

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

C++: #include <bits/stdc++.h>

using namespace std;

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

    vector<int> student;
    for(int i = 0;i < n;++i){
      int m,e,j;
      cin>>m>>e>>j;

      if(m == 100 || e == 100 || j == 100 || e + m >= 180 || e + m + j >= 240){
        student.push_back(0);
        continue;
      }
      if(e + m + j >= 210 || (e + m + j >= 150 && (m >= 80 || e >= 80))){
        student.push_back(1);
        continue;
      }
      student.push_back(2);
    }

    for(int e : student){
      if(e == 0){
        cout<<"A"<<endl;
      }
      else if(e == 1){
        cout<<"B"<<endl;
      }
      else{
        cout<<"C"<<endl;
      }
    }
  }

  return 0;
}

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

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
int p[3];
void judge(){
  REP(j,3){
    if(p[j]==100){
      cout<<"A"<<endl;
      return;
    }
  }
  if(p[0]+p[1]>=180){
    cout<<"A"<<endl;
    return;
  }
  int sum=0;
  REP(j,3)sum+=p[j];
  if(sum>=240){
    cout<<"A"<<endl;
    return ;
  }
  if(sum>=210){
    cout<<"B"<<endl;
    return ;
  }
  if(sum>=150&&(p[0]>=80||p[1]>=80)){
    cout<<"B"<<endl;
    return ;
  }
  cout<<"C"<<endl;
}
int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    REP(i,n){
      REP(j,3)cin>>p[j];
      judge();
    }
  }

  return 0;
}

C++: #include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while( true ) {
        int n;
        cin >> n;
        if( n == 0 ) break;

        for( int i = 0; i < n; ++i ) {
            int a, b, c;
            cin >> a >> b >> c;
            char cl = 'C';
            if( ( a + b + c ) / 3 >= 50 && ( a >= 80 || b >= 80 ) ) cl = 'B';
            if( ( a + b + c ) / 3 >= 70 ) cl = 'B';
            if( ( a + b + c ) / 3 >= 80 ) cl = 'A';
            if( ( a + b ) / 2 >= 90 ) cl = 'A';
            if( a == 100 || b == 100 || c == 100 ) cl = 'A';
            cout << cl << endl;

        }
    }

    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
#define MAX 10100
    int n; //生徒数
    int pm[MAX], pe[MAX], pj[MAX];
    //数学の点数、英語の点数、国語の点数

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

        for(int i = 0; i < n; i++){
            cin >> pm[i] >> pe[i] >> pj[i];
        }
        
        int mean_me[MAX]; //数学と英語の平均点
        int c[MAX]; //配属されるクラス

        for(int i = 0; i < n; i++){
            if(pm[i] == 100 || pe[i] == 100 || pj[i] == 100) 
                c[i] = 1;

            else if((pm[i] + pe[i]) / 2 >= 90)
                c[i] = 1;

            else if((pm[i] + pe[i] + pj[i]) / 3 >= 80)
                c[i] = 1;

            else if((pm[i] + pe[i] + pj[i]) / 3 >= 70)
                c[i] = 2;

            else if((pm[i] + pe[i] + pj[i]) / 3 >= 50 && (pm[i] >= 80 || pe[i] >= 80))
                c[i] = 2;
            
            else 
                c[i] = 3;

            if(c[i] == 1) cout << "A" << endl;
            else if(c[i] == 2) 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==0)break;
		for(i=0;i<n;i++){
			flg=0;
			scanf("%d %d %d",&m,&e,&j);
			if(m==100||e==100||j==100||(m+e)/2>=90||(m+e+j)/3>=80){
				cls[i]=1;
				flg=1;
			}
			if((m+e+j)/3>=70){
				flg++;
				cls[i]=2;
			}
			if((m+e+j)/3>=50&&(m>=80||e>=80)){
				flg++;
				cls[i]=2;
			}
			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++: // 2011/07/20 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;
}