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>


char dividing(int math, int english, int japanese)
{
    if (math == 100 || english == 100 || japanese == 100) {
        return 'A';
    } else if ((math + english) / 2 >= 90) {
        return 'A';
    } else if ((math + english + japanese) / 3 >= 80) {
        return 'A';
    } else if ((math + english + japanese) / 3 >= 70) {
        return 'B';
    } else if ((math + english + japanese) / 3 >= 50) {
        if (math >= 80 || english >= 80) {
            return 'B';
        } else {
            return 'C';
        }
    } else {
        return 'C';
    }
}


int main()
{
    int math, english, japanese, n;  //n:size of dataset
    std::cin >> n;
    while (n != 0) {
        for (int i = 0; i < n; i++) {
            std::cin >> math >> english >> japanese;
            std::cout << dividing(math, english, japanese) << std::endl;
        }
        std::cin >> n;
    }
    return 0;
}

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

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

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

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;
const double EPS  = 1e-10;

int main() {
	int n;
	while (cin >> n, n) {
		REP(i, n) {
			int m, e, j;
			scanf("%d %d %d", &m, &e, &j);
			
			int sum = m + e + j;
			int sum2 = m + e;
			
			int grade = 2;
			if (sum >= 150 && (m >= 80 || e >= 80)) grade = 1;
			if (sum >= 210) grade = 1;
			if (sum >= 240) grade = 0;
			if (sum2 >= 180) grade = 0;
			if (m == 100 || e == 100 || j == 100) grade = 0;
			
			printf("%c\n", grade + 'A');
		}
	}
	return 0;
}

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

char getAns(int m,int e,int j){
	if(m==100||e==100||j==100)return 'A';
	if((m+e)/2>=90)return 'A';
	if((m+e+j)/3>=80)return 'A';
	if((m+e+j)/3>=70)return 'B';
	if((m+e+j)/3>=50&& (m>=80||e>=80))return 'B';
	return 'C';

}
int main(){
	int d;
	while(cin>>d){
		int pm,pe,pj;
		for(;d>0;d--){
			cin>>pm>>pe>>pj;
			cout<<getAns(pm,pe,pj)<<endl;
		}
	}
}

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

bool isA( int a, int b, int c )
{
    if ( a == 100 || b == 100 || c == 100 ) return true;
    if ( ( a + b ) / 2 >= 90 || ( a + b + c ) / 3 >= 90 ) return true;
    return false;
}

bool isB( int a, int b, int c )
{
    if ( ( a + b + c ) / 3 >= 70 ) return true;
    if ( ( a + b + c ) / 3 >= 50 && ( a >= 80 || b >= 80 ) ) return true;
    return false;
}

void printClass( int a, int b, int c )
{
    if ( isA( a, b, c ) ) cout << "A" << endl;
    else if ( isB( a, b, c ) ) cout << "B" << endl;
    else cout << "C" << endl;
}

int main( void )
{
    int n;

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

    return 0;
}

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

int main(void)
{
    int n, pm, pe, pj;
    scanf("%d", &n);
    for (int i = 0;i < n;i ++){
	scanf("%d %d %d", &pm, &pe, &pj);
    
	if (class(pm, pe, pj) == 1){
	    printf("A\n");
	} else if (class(pm, pe, pj) == 2){
	    printf("B\n");
	} else {
	    printf("C\n");
	}
    }
    return 0;
}

int class(int pm, int pe, int pj)
{
    int ave = (pm + pe + pj) / 3;
    if (pm == 100 || pe == 100 || pj == 100){
	return 1;
    } else if ((pm + pe) / 2 >= 90){
	return 1;
    } else if (ave >= 80){
	return 1;
    } else if (ave >= 70){
	return 2;
    } else if (ave >= 50 && (pm >= 80 || pe >= 80)){
	return 2;
    } else {
	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<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>=90){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)/3>=80){
				cls[i]=1;
				flg++;
			}
			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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
int main() {
	while (true) {
		int n;
		scanf("%d", &n);
		if (n == 0) break;
		for (int i = 0;i < n;++i) {
			int m, e, j;
			scanf("%d%d%d", &m, &e, &j);
			if (m == 100 || e == 100 || j == 100 || (m + e) / 2 >= 90 || (m + e + j) / 3 >= 80) {
				printf("A\n");
			}
			else if ((m + e + j) / 3 >= 70 || ((m + e + j) / 3 >= 50 && (m >= 80 || e >= 80))) {
				printf("B\n");
			}
			else {
				printf("C\n");
			}
		}
	}
}

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;
        }
    }
}

C++: #include <iostream>

using namespace std;

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

C++: #include<iostream>

using namespace std;

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

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