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<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;

const ll INF = 1ll<<29;
const ll MOD = 1000000007;

int main()
{
	int n;
	while (cin >> n, n) {
		vector<char> rank(n);

		for (int i = 0; i < n; i++) {
			int pm, pe, pj;

			cin >> pm >> pe >> pj;

			double pm_pe_avg = (pm + pe) / 2.0;
			double all_avg = (pm + pe + pj) / 3.0;
			if (pm == 100 || pe == 100 || pj == 100) {
				rank[i] = 'A';
			}
			else if (pm_pe_avg >= 90 || all_avg >= 80)
				rank[i] = 'A';
			else if (all_avg >= 70 || (all_avg >= 50 && (pm >= 80 || pe >= 80))) {
				rank[i] = 'B';
			}
			else
				rank[i] = 'C';
		}
		for (int j = 0; j < n; j++)
			cout << rank[j] << endl;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){

  int in, math, eng, jap;

  while(1){

    cin >> in;

    if(in == 0) break;

    for(int i = 0; i < in; i++){
      cin >> math >> eng >> jap;

      if(math == 100 || eng == 100 || jap == 100){
	cout << "A";
      }else if((math + eng) / 2 >= 90){
	cout << "A";
      }else if((math + eng + jap) / 3 >= 80){
	cout << "A";
      }else if((math + eng + jap) / 3 >= 70){
	cout << "B";
      }else if((math + eng + jap) / 3 >= 50 && math >= 80){
	cout << "B";
      }else if((math + eng + jap) / 3 >= 50 && eng >= 80){
	cout << "B";
      }else{
	cout << "C";
      }
      cout << endl;
    }
  }

  return 0;
}

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

const double EPS = 1e-8;

int main()
{
    int n, pm, pe, pj;
    while(cin >> n && n) {
        for(int i = 0; i < n; i++) {
            cin >> pm >> pe >> pj;
            char cls = 'X';
            double ave_me, ave_all;
            ave_me = (double)(pm + pe) / 2;
            ave_all = (double)(pm + pe + pj) / 3;
            if(pm == 100 || pe == 100 || pj == 100)
                cls = 'A';
            else if(ave_me + EPS > 90)
                cls = 'A';
            else if(ave_all + EPS > 80) 
                cls = 'A';
            else if(ave_all + EPS > 70)
                cls = 'B';
            else if(ave_all + EPS > 50 && (pm>= 80 || pe >= 80))
                cls = 'B';
            else
                cls = 'C';
            
            cout << cls << endl;
        }
    }
}

C++: #include <stdio.h>

int classjudge(int pm,int pe,int pj){
    int class;
    if(pm == 100 || pe== 100 || pj== 100)class=0;
    else if(pm + pe >= 180)class=0;
    else if(pm + pe + pj >= 240)class=0;
    else if(pm + pe + pj >= 210)class=1;
    else if((pm + pe + pj >= 150) && (pm >= 80 || pe >= 80))class=1;
    else class=2;
    return class;
}

int main(void){
    int n,pm,pe,pj;
    while(scanf("%d",&n) != EOF && n != 0){
        for(int i=0;i < n;i++){
            scanf("%d %d %d",&pm,&pe,&pj);
            printf("%c\n",'A' + classjudge(pm,pe,pj));
        }
    }
    return 0;
}

C++: #include <stdio.h>
void judge(int pm, int pe, int pj)
{
    char class;
    if(pm == 100 || pe == 100 || pj == 100){
        class='A';
    }else if(pm + pe >= 180){
        class='A';
    }else if(pm + pe + pj >= 240){
        class='A';
    }else if(pm + pe + pj >= 210){
        class='B';
    }else if(pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)){
        class='B';
    }else{
        class='C';
    }
    printf("%c\n", class);
}

int main(void)
{
    int dataset;
    int pm, pe, pj;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &pm, &pe, &pj);
                judge(pm, pe, pj);
            }
        }
    }

    return 0;
}

C++: #include<iostream>

using namespace std;
 
void dist(int math, int eng, int jap){
  int av = (math + eng + jap) / 3;

  if(math == 100 || eng ==100 || jap ==100){
    cout << 'A' << endl;
  }else if((math + eng) / 2 >= 90){
    cout << 'A' << endl;
  }else if(av >= 80){
    cout << 'A' << endl;
  }else if(av >= 70){
    cout << 'B' << endl;
  }else if(av >= 50 && (math >= 80 || eng >= 80)){
    cout << 'B' << endl;
  }
  else{
    cout << 'C' << endl;
  }
       
}
 
int main(){
   
  int n,pm,pe,pj;
 
  while(cin >> n){
    if(n == 0){ 
      break;
    }
    for(int i = 0; i < n; i++){
      cin >> pm >> pe >> pj;
      dist(pm,pe,pj);
    }
  }
  return 0;
}

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

int main() {
    int N;
    while (cin >> N, N) {
        for (int i = 0; i < N; i++) {
            int x, y, z;
            cin >> x >> y >> z;
            if (max(max(x, y), z) == 100) {
                cout << "A" << endl;
            }
            else if ((x + y) / 2 >= 90) {
                cout << "A" << endl;
            }
            else if ((x + y + z) / 3 >= 80) {
                cout << "A" << endl;
            }
            else if ((x + y + z) / 3 >= 70) {
                cout << "B" << endl;
            }
            else if ((x + y + z) / 3 >= 50 && max(x, y)>=80) {
                cout << "B" << endl;
            }
            else {
                cout << "C" << endl;
            }
        }
    }

    return 0;
}

C++: #define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	while (1)
	{
		int n;
		cin >> n;

		if (n == 0)
		{
			break;
		}

		for (int i = 0; i < n; i++)
		{
			int a, b, c;
			cin >> a >> b >> c;

			string r = "C";
			if (a == 100 || b == 100 || c == 100 || (a + b + c >= 240) || (a + b >= 180))
			{
				r = "A";
			}
			else if ((a + b + c >= 210) || (a + b + c >= 150 && (a >= 80 || b >= 80)))
			{
				r = "B";
			}

			cout << r << endl;
		}
	}

}

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