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,pm[10001],pe[10001],pj[10001],i,x[10001],y[10001];
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&pm[i],&pe[i],&pj[i]);
			x[i]=(pm[i]+pe[i])/2;
			y[i]=(pm[i]+pe[i]+pj[i])/3;
		}
		for(i=0;i<n;i++){
			if(pm[i]==100||pe[i]==100||pj[i]==100) printf("A\n");
			else if(x[i]>=90||y[i]>=80) printf("A\n");
			else if(y[i]>=70||y[i]>=50&&pm[i]>=80||pe[i]>=80) printf("B\n");
			else printf("C\n");
		}
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int pm,pe,pj,pa,cl;
  int i=0,l;
  char a[100000];
  cin>>cl;
  while(cl!=0){
    l=i;
    for(int j=0;j<cl;j++){
      cin>>pm>>pe>>pj;
      pa=(pm+pe+pj)/3;
      if(pm==100||pe==100||pj==100||90<=(pm+pe)/2||80<=pa)a[i]='A';
      else if(70<=pa||80<=pe||80<=pm)a[i]='B';
      else a[i]='C';
      i++;
    }
    for(int j=l;j<i;j++)
      cout<<a[j]<<endl;
    cin >> cl;
  }
  
  
  return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
  int n;
  while(1){
    cin>>n;
    if(!n)break;
    int pm,pe,pj;
    rep(i,n){
      cin>>pm>>pe>>pj;
      int average=(pm+pe+pj)/3;
      if(pm==100 || pe==100 || pj==100)cout<<"A"<<endl;
      else if((pm+pe)/2>=90)cout<<"A"<<endl;
      else if(average>=80)cout<<"A"<<endl;
      else if(average>=70)cout<<"B"<<endl;
      else if(average>=50 &&(pm>=80 || pe>=80))cout<<"B"<<endl;
      else cout<<"C"<<endl;
    }
  }
  return 0;
}

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

int main() {
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		for (int b = 0; b < a; b++) {
			int d, e, f;
			cin >> d >> e >> f;
			if (d==100|| d==100 || d==100 || d + e > 179 || d + e + f > 239)cout << "A";
			else if ((d + e + f > 209) || (d + e + f > 149) && (d > 79 || e > 79))cout << "B";
			else cout << "C";
			cout << endl;
		}
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,a1,a2,a3,i,sum=0,avg=0;
	while(1){
		cin>>a;
		if(a==0) break;
		for(i=0;i<a;i++){
			cin>>a1>>a2>>a3;
			sum=a1+a2+a3;
			avg=sum/3;
			if(a1==100||a2==100||a3==100||avg>=80||(a1+a2)/2>=90)
				printf("A\n");
			else if(avg>=70||avg>=50&&a1>=80||avg>=50&&a2>=80)
				printf("B\n");
			else
				printf("C\n");
		}
	}
	return 0;
}

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

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

int main(){
    int n;
    int ja,ma,en;
    while(1){
        cin >> n;
        if(n == 0) break;
        for(int i=0;i<n;i++){
            cin >> ma >> en >> ja;
            if(ma == 100 || en == 100 || ja == 100){
                cout << "A" << endl;
            }
            else if((ma + en) / 2 >= 90){
                cout << "A" << endl;
            }
            else if((ma + en + ja) / 3 >= 80){
                cout << "A" << endl;
            }
            else if((ma + en + ja) / 3 >= 70){
                cout << "B" << endl;
            }
            else if((ma + en + ja) / 3 >= 50 && (ma >= 80 || en >= 80)){
                cout << "B" << endl;
            }
            else {
                cout << "C" << endl;
            }
        }
    }
}

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

int main(){
    int n;
    while(cin>>n,n){
        while(n--){
            int a,b,c;cin>>a>>b>>c;
            if((a==100||b==100||c==100)||a+b>=180||a+b+c>=240){
                cout<<"A"<<endl;
            }
            else if(a+b+c>=210||(a+b+c>=150&&(a>=80||b>=80))){
                cout<<"B"<<endl;
            }
            else cout<<"C"<<endl;
        }
    }
    return 0;
}

C++: #include <stdio.h>

char divide(int math, int english, int japanese);
char class;

int main(void)
{
    int dataset;
    int math, english, japanese;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &math, &english, &japanese);
                class = divide(math, english, japanese);
                printf("%c\n", class);
            }
        }
    }

    return 0;
}

char divide(int math, int english, int japanese)
{
    int sum = math + english + japanese;

    if (math == 100 || english == 100 || japanese == 100){
        class = 'A';
    } else if (math + english >= 90 * 2){
        class = 'A';
    } else if (sum >= 80 * 3){
        class = 'A';
    } else if (sum >= 70 * 3){
        class = 'B';
    } else if (sum >= 50 * 3 && (math >= 80 || english >= 80)){
        class = 'B';
    } else {
        class = 'C';
    }

    return class;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
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;
            int heikin = 0;
            cin >> pm >> pe >> pj;
            heikin = pm + pe + pj;
            heikin /= 3;
            if(pm == 100 || pe == 100 || pj == 100) cout << "A" << endl;
            else if((pm + pe) / 2 >= 90) cout << "A" << endl;
            else if(heikin >= 80) cout << "A" << endl;
            else if(heikin >= 70) cout << "B" << endl;
            else if(heikin >= 50 && pm >= 80 || pe >= 80) cout << "B" << endl;
            else cout << "C" << endl;
        }
    }
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;


int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(!n) break;

        for(int i=0;i<n;i++){
            int pm,pe,pj;
            scanf("%d%d%d",&pm,&pe,&pj);
            int ave = (pm+pe+pj)/3;
            if((pm==100||pe==100||pj==100) || (pm+pe)/2>=90 || ave>=80){
                cout << "A" << endl;
            }else if(ave>=70 || (ave>=50&&(pm>=80||pe>=80))){
                cout << "B" << endl;
            }else{
                cout << "C" << endl;
            }
        }
    }

    return 0;
}