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>
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>=90*2){
				cls[i]=1;
				flg++;
			}
			if(m+e+j>=80*3){
				cls[i]=1;
				flg++;
			}
			if(m+e+j>=70*3){
				cls[i]=2;
				flg++;
			}
			if(m+e+j>=50*3&&(m>=80||e>=80)){
				cls[i]=2;
				flg++;
			}
			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(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++){
			int b,c,d;
			scanf("%d%d%d",&b,&c,&d);
			if(b==100||c==100||d==100||b+c>=180||b+c+d>=240)printf("A\n");
			else if(b+c+d>=210||(b+c+d>=150&&(b>=80||c>=80)))printf("B\n");
			else printf("C\n");
		}
	}
}

C++: #include<stdio.h>
int main(){
    int a;
    while(scanf("%d",&a),a){
        for(int i=0;i<a;i++){
            int b,c,d;
            scanf("%d%d%d",&b,&c,&d);
            if(b==100||c==100||d==100||b+c>=180||b+c+d>=240)printf("A\n");
            else if(b+c+d>=210||(b+c+d>=150&&(b>=80||c>=80)))printf("B\n");
            else printf("C\n");
        }
    }
}

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)
{
    float mean_2 = mean2(p_math, p_eng);
    float mean_3 = mean3(p_math, p_eng, p_jpn);
    
    if ( p_math == 100 || p_eng == 100 || p_jpn == 100) {
        return 'A';
    } else if (mean_2 >= 90.0) {
        return 'A';
    } else if (mean_3 >= 80.0) {
        return 'A';
    } else if (mean_3 >= 70.0) {
        return 'B';
    } else if (mean_3 >= 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 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||(m+e)/2>=90||(m+e+j)/3>=80){
				cls[i]=1;
				flg=1;
			}
			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==0){
				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;
	while(1){
	    scanf("%d",&n);
	    if (n==0) {
    		break;
		}
		else {
			for (i=0;i<n;i++){
				scanf("%d %d %d",&pm,&pe,&pj);
				s=(pm+pe)/2;
				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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int n;
	int pm,pe,pj;
	while(n=in()){
		int i;
		for(i=0;i<n;i++){
			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;
			}
		}
	}
	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;
        }
    }
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n;
    while(true){
        cin>>n;
        if(n==0)    break;
        else{
            int i;
            for(i=0;i<n;i++){
                int m,e,j;
                cin>>m>>e>>j;
                if(m==100)  cout<<"A";
                else if(e==100) cout<<"A";
                else if(j==100) cout<<"A";
                else if(m+e>=180)   cout<<"A";
                else if(m+e+j>=240) cout<<"A";
                else if(m+e+j>=210) cout<<"B";
                else if(m+e+j>=150){
                    if(m>=80||e>=80)   cout<<"B";
                    else cout<<"C";
                }
                else    cout<<"C";
                cout<<endl;
            }
        }
    }
}

C++: #include<iostream>
#include<string>

using namespace std;

int main(void){
	while(1){
		int a,n;
		char str[10001];
		cin >> n;
		if(n==0)break;
		for(a=0;a<n;a++){
			int m,e,j;
			cin >> m >> e >> j;
			if(m==100 || e==100 || j==100)str[a]='A';
			else if(m+e>=180)str[a]='A';
			else if(m+e+j>=240)str[a]='A';
			else if(m+e+j>=210)str[a]='B';
			else if(m+e+j>=150 && m>=80 || e>=80)str[a]='B';
			else str[a]='C';
		}
		for(a=0;a<n;a++){
			cout << str[a] << endl;
		}

	}
}

C++: #include<stdio.h>
int main(void)
{
    float 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;
	}
	
}