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>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
class state{
public:
  int p,d;
  bool operator<(const state & a)const{
    if (d != a.d)return d > a.d;
    return p < a.p;
  }
};

main(){
  int n;
  while(cin>>n&&n ){
    rep(i,n){
      int m,e,j;
      cin>>m>>e>>j;
      if (m>=100||e>=100||j>=100||(m+e)>=2*90 ||m+e+j >= 3*80)cout << "A"<<endl;
      else if (m+e+j>= 3*70 || (m+e+j>=3*50 && (m>=80||e>=80)))cout <<"B"<<endl;
      else cout << "C" << endl;
    }
  }
}

C++: #include <iostream>

char DividingStudent(int pm, int pe, int pj)
{
    if (pm==100 || pm==100 || pj==100) {
        return 'A';
    } else if ((pm+pe)/2 >= 90){
        return 'A';
    } else if ((pm+pe+pj)/3 >= 80){
        return 'A';
    } else if ((pm+pe+pj)/3 >= 70){
        return 'B';
    } else if ((pm+pe+pj)/3 >= 50 && (pm>=80 || pe>=80)) {
        return 'B';
    } else {
        return 'C';
    }
}

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

C++: #include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<char, int>P;

int main() {
	int n;
	while (cin >> n, n) {
		rep(i, n) {
			int p, q, r; cin >> p >> q >> r;
			if (p == 100 || q == 100 || r == 100)puts("A");
			else if (p + q >= 180)puts("A");
			else if (p + q + r >= 240)puts("A");
			else if (p + q + r >= 210)puts("B");
			else if (p + q + r >= 150 && (p >= 80 || q >= 80))puts("B");
			else puts("C");
		}
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, a, b, c;
	vector<char>l;
	while (true){
		cin >> n;
		if (n == 0){
			break;
		}
		else{
			for (int i = 0; i < n; i++){
				cin >> a >> b >> c;
				if (a == 100 || b == 100 || c || 100){
					l[i] = 'A';
				}
				else if (a + b >= 180){
					l[i] = 'A';
				}
				else if (a + b + c >= 240)
				{
					l[i] = 'A';
				}
				else if (a + b + c >= 210){
					l[i] = 'B';
				}
				else if (a + b + c >= 150 && a >= 80){
					l[i] = 'B';
				}
				else if (a + b + c >= 150 && b >= 80) {
					l[i] = 'B';
				}
				else l[i] = 'C';
			}
		}
	}
	for (int i = 0; i != l.size(); i++)
	{
		cout << l[i] << endl;
	}
}

C++: #include <stdio.h>
char classify(int pm, int pe, int pj);

int main(void)
{
    int n, pm, pe, pj;
    while (true) {
	scanf("%d", &n);
	if (n == 0){
	    break;
	} else {
	    for (int i = 0;i < n;i ++){
		scanf("%d %d %d", &pm, &pe, &pj); 
		printf("%c\n", classify(pm, pe, pj));
	    }
	}
	return 0;
    }
}

char classify(int pm, int pe, int pj)
{
    int ave = (pm + pe + pj) / 3;
    if (pm == 100 || pe == 100 || pj == 100){
	return 'A';
    } else if ((pm + pe) / 2 >= 90){
	return 'A';
    } else if (ave >= 80){
	return 'A';
    } else if (ave >= 70){
	return 'B';
    } else if (ave >= 50 && (pm >= 80 || pe >= 80)){
	return 'B';
    } else {
	return 'C';
    }
}

C++: #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;
            char output;
            if ((pm == 100 || pe == 100 || pj == 100)
                || (180 <= pm + pe)
                || (240 <= pm + pe + pj)) {
                output = 'A';
            } else if ((210 <= pm + pe + pj)
                       || (150 <= pm + pe + pj && (80 <= pm || 80 <= pe))) {
                output = 'B';
            } else {
                output = 'C';
            }
            cout << output << endl;
        }
    }
}

C++: #include<iostream>
using namespace std;
int main(){
	for(int n;cin>>n,n;){
		while(n--){
			int m,e,j;	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 && (m>=80 || e>=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 <stdio.h>

float mean2(int x, int y)
{
    return (float)(x + y) / 2.0;
}

float mean3(int x, int y, int z)
{
    return (float)(x + y + z) / 3.0;
}

char grading(int p_math, int p_eng, int p_jpn)
{
    if ( p_math == 100 || p_eng == 100 || p_jpn == 100) {
        return 'A';
    } else if (mean2(p_math, p_eng) >= 90.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 80.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0) {
        return 'B';
    } else if (mean3(p_math, p_eng, p_jpn) >= 50.0 && (p_math >= 80 || p_eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    int i, p_math, p_eng, p_jpn, n_iteration;
    char grade;

    while (1) {
        scanf("%d", &n_iteration);

        if (n_iteration == 0) {
            break;
        }

        for (i = 0; i < n_iteration; i++) {
            scanf("%d %d %d", &p_math, &p_eng, &p_jpn);
            grade = grading(p_math, p_eng, p_jpn);
            printf("%c\n", grade);
        }
    }
    return 0;
}

C++: #include <stdio.h>

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

C++: #include <iostream>

char DividingStudent(int pm, int pe, int pj)
{
    if (pm==100 || pm==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 << DividingStudent(pm, pe, pj) << std::endl;
        }
    }
}