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>
using namespace	std;

int main() {
  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 && (e >= 80 || m >= 80))
	cout << "B" << endl;
      else
	cout << "C" << endl;
    }
  }
  return 0;
}

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

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){
				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&&(m+e+j)/3<80){
				flg++;
				cls[i]=2;
			}
			if(((m+e+j)/3>=50&&(m+e+j)/3<80)&&((m>=80&&m<100)||(e>=80&&e<100))){
				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++: #include<stdio.h>
int main(void)
{
    int n,pm,pe,pj,i,s,d;
	scanf("%d",&n);
	while(1){
	    if (n==0)  break;
		for (i=0;i<n;i++){
			scanf("%d %d %d",&pm,&pe,&pj);
			s=(pm+pe)/2.0;
			d=(pm+pe+pj)/3;
			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>
using namespace std;
int main(){
	int n,pm,pj,pe;
	while(n){
		cin>>n;
		for( int i=0; i<n; i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pj==100||pe==100){
				cout<<"A"<<endl;
			}else if((pm+pe)/2>=90){
				cout<<"A"<<endl;
			}else if((pm+pj+pe)/3>=70){
				cout<<"B"<<endl;
			}else if((pm+pe+pj)/3>=50&&pm>=80||pe>=80){
				cout <<"B"<<endl;
			}else if((pm+pj+pe)/3<=50){
				cout<<"C"<<endl;
			}
		}
	}
	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)/2.0 >= 80+EPS)cout << "A" << endl;
      else if((A+B+C)/3.0 >= 70+EPS)cout << "B" << endl;
      else if((A+B+C)/3.0>=50+EPS && (A>=80 || B>=80))cout << "B" << endl;
      else cout << "C" << endl;
    }
  }
  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);
		}
	}
	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int n;

  while(1) {
    cin >> n;
    if(!n) break;

    REP(i, n) {
      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; 
    }
  }
}

C++: 
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		rep(i, n) {
			int pm, pe, pj;
			cin >> pm >> pe >> pj;

			int ave = (pm + pe + pj) / 3;
			int me_ave = (pm + pe) / 2;
			if (pm == 100 || pe == 100 || pj == 100 || ave >= 80 || me_ave >= 90)
				cout << 'A' << endl;
			else if (ave >= 70 || (ave >= 50 && (pm >= 80 || pe >= 80)))
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
	return	0;
}

C++: #include <stdio.h>

int weather_right_triangle(int, int, int);

int main(void)
{
	int n;
	scanf("%d", &n);
	int a[n][3];
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
		weather_right_triangle(a[i][0], a[i][1], a[i][2]);
	}
	return 0;
}

int weather_right_triangle(int a, int b, int c)
{
	if (a * a + b * b == c * c || 
		b * b + c * c == a * a || 
		a * a + c * c == b * b) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}