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<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
class data{
public:
    int pm,pe,pj,rank;
    double me(){return (double)(pm+pe)/2;};
    double ave(){return (double)(pm+pe+pj)/3;}
    int maxi(){return max(max(pm,pe),pj);};
};
int main(){
    int n;
    while(cin>>n){
        if(!n)return 9;
        vector<data>v(n+1);
        v.clear();
        rep(i,n){
            cin>>v[i].pm>>v[i].pe>>v[i].pj;
            if(v[i].me()>=90||v[i].ave()>=80||v[i].maxi()==100){
                v[i].rank=3;
            }else if(v[i].ave()>=70||(v[i].ave()>=50&&(v[i].pe>=80||v[i].pm>=80)))
                v[i].rank=2;
            else
                v[i].rank=1;
            switch (v[i].rank) {
                case 1:
                    cout<<"C"<<endl;
                    break;
                case 2:
                    cout<<"B"<<endl;
                    break;
                default:
                    cout<<"A"<<endl;
                    break;
            }
        }
    }
}

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

C++: #include <iostream>


void f(int pm, int pe, int pj)
{
	double ave = (pm + pe + pj) / 3;
	if (pm == 100 || pe == 100 || pj == 100) {
		std::cout << "A" << std::endl;
	} else if ((pm + pe) / 2 >= 90 || ave >= 80) {
		std::cout << "A" << std::endl;
	} else if (ave >= 70 && (pm >=80 || pe >= 80)) {
		std::cout << "A" << std::endl;
	} else if ( ave >= 70 && (pm < 80 && pe < 80)) {
			std::cout << "B" << std::endl;
	} else if (ave >= 50 && ave < 70 && (pm >= 80 || pe >= 80)) {
		std::cout << "B" << std::endl;
	} else {
		std::cout << "C" << std::endl;
	}
}
int main()
{
	while (true){
	    int n;
		std::cin >> n;
		if (n == 0) {
			break;
		} else {
	        for (int i = 0; i < n; i++) {
		        int pm;
		        int pe;
		        int pj;
		        std::cin >> pm >> pe >> pj;
				    f(pm, pe, pj);
			}
		}
	}
	return 0;
}

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

int main(){
    while(1){
        int n;
        cin>>n;
        if(n==0){
            break;
        }
        for(int i=0; i<n; i++){
            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){
                cout<<"B"<<endl;
            }else if( (m+e+j)/3>=50 &&m>=80){
                cout<<"B"<<endl;
            }else if( (m+e+j)/3>=50 &&e>=80){
                cout<<"B"<<endl;
            }else{
                cout<<"C"<<endl;
            }
        }
    }
}

C++: #include <iostream>


void f(int pm, int pe, int pj)
{
	double ave = (pm + pe + pj) / 3;
	if (pm == 100 || pe == 100 || pj == 100) {
		std::cout << "A" << std::endl;
	} else if ((pm + pe) / 2 >= 90 || ave >= 80) {
		std::cout << "A" << std::endl;
	} else if (ave >= 70 && (pm >=80 || pe >= 80)) {
		std::cout << "A" << std::endl;
	} else if ( ave >= 70 && (pm < 80 && pe < 80)) {
			std::cout << "B" << std::endl;
	} else if (ave >= 50 && ave < 70 && (pm >= 80 || pe >= 80)) {
		std::cout << "B" << std::endl;
	} else {
		std::cout << "C" << std::endl;
	}
}
int main()
{
	while (true){
	    int n;
		std::cin >> n;
		if (n == 0) {
			break;
		} else {
	        for (int i = 0; i < n; i++) {
		        int pm;
		        int pe;
		        int pj;
		        std::cin >> pm >> pe >> pj;
				    f(pm, pe, pj);
			}
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
char hyakuten(int students[][3],int n){
  for(int i=0;i<3;i++){
   if(students[n][i]==100)return 'A';
  }
  if((students[n][0]+students[n][1])/2>=90)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=80)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=70)return 'B';
  if((students[n][0]+studnets[n][1]+students[n][2])/3>=50&&students[n][0]>=80||students[n][1]>=80)return 'B';
  return 'C';
}


int main(){
  int n;
  while(cin>>n&&n){
    int students[10000][3];
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        cin>>students[i][j];
      }
    }
    for(int i=0;i<n;i++){
      cout<<hyakuten(i)<<endl;
    }
  }
  return 0;
}

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

int main(void)
{
    int n, pm, pe, pj;
    while (1) {
	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(void){

	while(1){
		int n,pm,pe,pj,pme,pmej,k[10000];
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin >> pm >> pe >> pj;
			pme=(pm+pe)/2;
			pmej=(pm+pe+pj)/3;
			if(pm==100||pe==100||pj==100||pme>=90||pmej>=80)k[i]=1;
			else if(pmej>=70||pmej>=50&&(pm>=80||pe>=80))k[i]=2;
			else k[i]=3;
		}
		for(int i=0;i<n;i++){
			if(k[i]==1)cout << "A" << endl;
			else if(k[i]==2)cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
	return 0;
}