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 <stdbool.h>

char dividing(int pm, int pe, int pj);

int main(void)
{
	int ninnzuu;
	int point[3];
	while(true) {
		scanf("%d", &ninnzuu);
		if(ninnzuu == 0) {
			break;
		}
		for(int i = 0; i < ninnzuu; i++) {
			scanf("%d %d %d", &point[0], &point[1], &point[2]);
			printf("%c\n", dividing(point[0], point[1], point[2]));
		}
	}
	return 0;
}

char dividing(int pm, int pe, int pj)
{
	if(pm == 100 || pe == 100 || pj == 100) {
		return 'A';
	}else 	if(pm + pe >= 180) {
		return 'A';
	}else 	if(pm + pe + pj >= 240) {
		return 'A';
	}else  	if(pm + pe + pj >= 210) {
		return 'B';
	}else  	if(pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)) {
		return 'B';
	}else{
		return 'C';
	}
}

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>=180){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)*3>=240){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)*3>=210){
				cls[i]=2;
				flg++;
			}
			if((m+e+j)*3>=150&&(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++: #include<<iostream>
#include<algorithm>
using namespace std;
char hyakuten(int *students[][3],int n){
  for(int i=0;i<3;i++){
   if(students[n][i]==100)return 'A';
  }
  if((students[n][0]+students[n][1])/2>=90)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=80)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=70)return 'B';
  if((studnets[n][0]+studnets[n][1]+students[n][2])/3>=50&&students[n][0]>=80||students[n][1]>=80)return 'B';
  return 'C';
}


int main(){
  int n;
  while(cin>>n&&n){
    int students[10000][3];
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        cin>>students[i][j];
      }
    }
    for(int i=0;i<n;i++){
      cout<<hyakuten(i)<<endl;
    }
  }
  return 0;
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n;
	
	while (cin >> n, n) {
		for_(i,0,n) {
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			
			double ave = (double)(pm + pe + pj) / 3.;
			double aveme = (double)(pm + pe) / 2.;
			
			if (aveme > 89 || pm == 100 || pe == 100 || pj == 100) {
				cout << "A" << endl;
			} else {
				
				if (ave < 50) {
					cout << "C" << endl;
				} else if (ave < 70) {
					if (pm >= 80 || pe >= 80) cout << "B" << endl;
					else cout << "C" << endl;
				} else if (ave < 80) {
					cout << "B" << endl;
				} else {
					cout << "A" << endl;
				}
			}
		}
	}
}

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

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

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

int main()
{
  int n, m, e, j;
  while(1)
  {
    cin >> n;
    if(!n)
      break;

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

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int M = 0, E = 1, J = 2;

int main()
{
    int n, p[3], sum, ave;
    while(cin >> n && n)
    {
        rep(j,n)
        {
            sum= 0;
            cin >> p[M] >> p[E] >> p[J];
            REP(3) sum+= p[i];
            ave = sum / 3;

            if(p[0] == 100|| p[1] == 100 || p[2] == 100 ||((p[M]+ p[E]) >= 180)|| (ave >= 80)){cout << "A"<< endl; continue;}
            //if((p[M]+ p[E]) >= 180) {cout << "A" << endl; continue;}
            //if(ave >= 80) { cout << "A" << endl; continue;}

            if(ave >= 70 || (ave >=50 && (p[M] >=80 || p[E] >= 80))){cout <<"B" << endl; continue;}

            cout << "C" << endl;
        }    
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,n;
  int ans;
  cin>>n;
  while(n!=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)>=180)cout<<"A"<<endl;
      else if((a+b+c)>=240)cout<<"A"<<endl;
      else if((a+b+c)>=210)cout<<"B"<<endl;
      else if((a+b+c)>=150&&(a>=80||b>=80))cout<<"B"<<endl;
      else cout<<"C"<<endl;
    }
    cin>>n;
  }
  return 0;
}

C++: #include <iostream>

char aizu(int pm, int pe, int pj)
{
    if (pm==100 || pe==100 || pj==100) {
        return 'A';
    } else if ((pm+pe) >= 180){
        return 'A';
    } else if ((pm+pe+pj) >= 240){
        return 'A';
    } else if ((pm+pe+pj) >= 210){
        return 'B';
    } else if ((pm+pe+pj) >= 150 && (pm>=80 || pe>=80)) {
        return 'B';
    } else {
        return 'C';
    }
}

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

C++: #include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int n,a,b,c;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			if(a==100||b==100||c==100) cout<<'A'<<endl;
			else{
				double A=(a+b+c)/3;
				if((double)(a+b)/2>=90) cout<<'A'<<endl;
				else if(A>=80) cout<<'A'<<endl;
				else if(A>=70) cout<<'B'<<endl;
				else if(A>=50&&(a>=80||b>=80)) cout<<'B'<<endl;
				else cout<<'C'<<endl;
			}
		}
	}
}