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>

int main(void)
{
    int n;
    int pm, pe, pj;
    int sum;
    while (true) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            for (int i = 0; i < n; ++i) {
                scanf("%d %d %d", &pm, &pe, &pj);
                sum = pm + pe + pj;
                if (pm == 100 || pe == 100 || pj == 100) {
                    printf("A\n");
                } else if (pm + pe >= 180) {
                    printf("A\n");
                } else if (sum >= 240) {
                    printf("B\n");
                } else if (sum >= 150 && (pm >= 80 || pe >= 80)) {
                    printf("B\n");
                } else {
                    printf("C\n");
                }
            }
        }
    }
    return 0;
}

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

C++: #include<stdio.h>
 
int main(void){
    int i,n,t1,t2,j,m,e;
    while(0==0)
    {
        scanf("%d",&n);
        if(n==0)break;
 
        for(i=0;i<n;i++){
            scanf("%d %d %d",&m,&e,&j);
            t1=m+e;  t2=m+e+j;
            if((m==100 || e==100 || j==100) || (t1>=180) || (t2>=240))
                printf("A\n");
            else if((t2>=210) || (t2>=150 && ( m>=80 || e>=80)))
                printf("B\n");
            else printf("C\n");
        }
    }
    return 0;
}

C++: #include<bits/stdc++.h>
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){
				printf("A\n");
			}
			else if(m+e>=180){
				printf("A\n");
			}
			else if(m+e+j>=240){
				printf("A\n");
			}
			else if(m+e+j>=210){
				printf("B\n");
			}
			else if(m+e+j>=150&&(m>=80||e>=80)){
				printf("B\n");
			}
			else{
				printf("C\n");
			}
			
		}
	}
	return 0;
}

C++: #include <iostream>

char calcClassOfStudent(int math, int english, int japanese);

int main()
{
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; ++i) {
            int math, english, japanese;
            std::cin >> math >> english >> japanese;
            std::cout << calcClassOfStudent(math, english, japanese) << std::endl;
        }
    }
    return 0;
}

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

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,pm,pe,pj;

int main(){
	while(cin>>n){
		if(!n)return 0;
		while(n--){
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||pj==100||pm+pe>179||pm+pe+pj>239)cout<<"A"<<endl;
			else if(pm+pe+pj>209||pm+pe+pj>149&&(pm>79||pe>79))cout<<"B"<<endl;
			else cout<<"C"<<endl;
		}
	}
}

C++: #include <iostream>

int Classification(int pm, int pe, int pj)
{
	if(pm == 100 || pe == 100 || pj == 100) {
		return 1;
	} else if ( ( pm + pe) / 2 >= 90) {
		return 1;
	} else if ( ( pm + pe + pj) / 3 >= 80) {
		return 1;
	} else if ( ( pm + pe + pj) / 3 >= 70) {
		return 2;
	} else if ( ( pm + pe + pj) /3 > 50 && ( pm >= 80 || pe >= 80)) {
		return 2;
	} else {
		return 3;
	}
}

char Class(int x)
{
	if ( x == 1) {
		return 'A';
	} else if ( x == 2) {
		return 'B';
	} else {
		return 'C';
	}
}

int main()
{
	int n, pm, pe, pj;
	
	while (true) {
		std::cin >> n;
		if ( n == 0){
			break;
		} else {
			for (int i = 0; i < n; i++) {
				std::cin >> pm >> pe >>pj;
				std::cout << Class(Classification(pm, pe, pj)) << std::endl;
			}
		}
	}
	
	return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    for (int i = 0; i < n; i++) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      if (pm == 100 || pe == 100 || pj == 100 ||
          pm + pe >= 180 ||
          pm + pe + pj >= 240)
        cout << 'A' << endl;
      else if (pm + pe + pj >= 210 ||
               pm + pe + pj >= 150 && (pm >= 80 || pe >= 80))
        cout << 'B' << endl;
      else
        cout << 'C' << endl;
    }
  }
}

C++: #include <cstdio>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int main(){
	int n;
	while(cin >> n){
	int t[3],tt[2];
	string ans[n];
	for(int i = 1;n >= i;i++){
		for(int ii = 1;3 >= ii;ii++){
			cin >> t[1] >> t[2] >> t[3];
			tt[1] = ( t[1] + t[2] ) / 2;
			tt[2] = ( t[1] + t[2] + t[3]) / 3;
			if(t[1] == 100 or t[2] == 100 or t[3] == 100 or  tt[1] >= 90 or t[2] >= 80){
				ans[i] = "A";
			}else if(tt[2] >= 70){
				ans[i] = "B";
			}else if(tt[2] >= 50 and t[1] >= 80 or tt[2] >= 50 and t[2] >= 80){
				ans[i] = "B";
			}else{
				ans[i] = "C";
			}
		}
	}
	for(int iii = 1;n >= iii;iii++){
		cout << ans[iii] << endl;
	}
}
}

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

		}
	}
}

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