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>
using namespace std;

int main(){
  int n;

  while(1){
    cin >> n;
    if( n == 0) break;
    for(int i = 0; i < n; i++){
      int m,e,j;
      cin >> m >> e >> j;
      double a = (m+e+j)/3;
      //      cout << "average " << a << endl;

      if(m == 100 || e == 100 || j == 100){
	cout << "A" << endl;
      }
      else if( double((m+e))/2 >= 90){
	cout << "A" << endl;
      }
      else if(a >= 80 ){
	cout << "A" << endl;
      }
      else if(a >=70 ){
	cout << "B" << endl;
      }
      else if(a >=50 ){
	if(m >= 80 || e >= 80){
	  cout << "B" << endl;
	}
	else{
	  cout << "C" << endl;
	}
      }
      else{
	cout << "C" << endl;
      }
    }

  }


  return 0;
}

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

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

	

}

C++: #include<stdio.h>
int main(void)
{
	int n,a,b,c,i,B,A;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);  B=0;
			if(a==100 || b==100 || c==100 || (a+b)/2>89 || (a+b+c)/3>79)  printf("A\n");
			else if((a+b+c)/3>69 && ((a+b+c)/3>49 && a>79 || b>79))  printf("A\n");
			else if((a+b+c)/3>69 || (a+b+c)/3>49 && a>79 || b>79)  printf("B\n");
			else printf("C\n");
		}
		scanf("%d",&n);
	}
	return 0;
}

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

int twoave(int a,int b)
{
	return (a+b)/2;
}
int theave(int a,int b,int c)
{
	return (a+b+c)/3;
}

int main()
{
	int n,pm,pe,pj;
	while(cin >> n){
		if(n==0)
			break;
		for(int i=0;i<n;i++){
			cin >> pm >> pe >> pj;
			if(pm==100 || pe==100 || pj==100)
				cout << 'A' << endl;
			else if(twoave(pm,pe)>=90)
				cout << 'A' << endl;
			else if(theave(pm,pe,pj)>=80)
				cout << 'A' << endl;
			else if(theave(pm,pe,pj)>=70)
				cout << 'B' << endl;
			else if(theave(pm,pe,pj)>=50 && (pm>=80 || pe>=80))
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,pj,pm,pe;
	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=1;i<=n;i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||pj==100){
				cout<<"A"<<endl;

			}else if((pm+pe)/2>=90){
				cout<<"A"<<endl;
			}else if((pm+pe+pj)/3>=80){
				cout<<"A"<<endl;
			}else if((pm+pe+pj)/3>=70){
				cout<<"B"<<endl;
			}else if((pm+pe+pj)/3>=50&&pe>=80||pm>=80){
				cout<<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	}
}

C++: //18
#include<iostream>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    while(n--){
      int m,e,j;
      cin>>m>>e>>j;
      if(m==100||e==100||j==100||m+e>=180||m+e+j>=240){
	cout<<'A'<<endl;
      }else if(m+e+j>=210||(m+e+j>=150&&(m>=80||e>=80))){
	cout<<'B'<<endl;
      }else{
	cout<<'C'<<endl;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    
    //変数：生徒の人数 「 n 」と置く
    int n;
    //変数：数学の点数「 mathematical 」、英語の点数「 english 」、国語の点数「 national 」と置く
    int mathematical, english, national;

    while(cin >> n, n){
        
        //繰返し：生徒数分、繰返しする
        for(int i = 0; i < n; i++){
        //条件：クラス分けの判断は問題見て
        cin >> mathematical >> english >> national;
            if( mathematical == 100 || english == 100 || national == 100 ) cout << "A" << endl;
            else if( 90 <= (mathematical + english) / 2 ) cout << "A" << endl;
            else if( 80 <= (mathematical + english + national) / 3 ) cout << "A" << endl;
            else if( 70 <= (mathematical + english + national) / 3 ) cout << "B" << endl;
            else if( 50 <= (mathematical + english + national) / 3 && 80 <= mathematical || 80 <= english ) cout << "B" << endl;
            else cout << "C" << endl;
        }
    }
    
    
}

C++: #include <iostream>

bool judgement_1(int a, int b, int c)
{
	if (a == 100 || b == 100 || c == 100 || a+b >= 180 || a+b+c >= 240) {
		return true;
	} else {
		return false;
	}
}

bool judgement_2(int a, int b, int c)
{
	if (a+b+c >= 210 || (a+b+c >= 150 && (a >= 80 || b >= 80) )) {
		return true;
	} else {
		return false;
	}
}

int main()
{
    int x;
	int y;
    int z;
	bool flag[2];
	int n;
	std::cin >> n;
	while (n > 0) {
	    std::cin >> x >> y >> z;
	    flag[0] = judgement_1(x, y, z);
	    flag[1] = judgement_2(x, y, z);
	    if (flag[0]) {
	    	std::cout << "A" << std::endl;
	    } else if (flag[1]) {
	    	std::cout << "B" << std::endl;
	    } else {
	    	std::cout << "C" << std::endl;
	    n --;
	   }
    }
}

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 <iostream>
using namespace std;

int main(){
  int n, m, e, j;

  while(1){
    cin >> n;
    if(n == 0) break;
    for(int i = 1; i <= n; i++){
      cin >> m >> e >> j;

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

  }
}

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

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