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 <cstdio>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

int main(){
	int n;
	
	while (cin >> n, n){
		REP(i,n){
			int m, e, j;
			
			scanf("%d %d %d", &m, &e, &j);
			
			if (m == 100 || e == 100 || j == 100){
				cout << "A" << endl;
			}
			else if (m+e >= 90*2){
				cout << "A" << endl;
			}
			else if (m+e+j >= 80*3){
				cout << "A" << endl;
			}
			else if (m+e+j >= 70*3){
				cout << "B" << endl;
			}
			else if (m+e+j >= 50*3 && (m >= 80 || e >= 80)){
				cout << "B" << endl;
			}
			else cout << "C" << endl;
		}
	}
	
	return 0;
}

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

C++: #include <stdio.h>

int cjudge(int pm,int pe,int pj){
    int c;//クラス
    if(pm == 100 || pe== 100 || pj== 100)c=0;
    else if(pm + pe >= 180)c=0;
    else if(pm + pe + pj >= 240)c=0;
    else if(pm + pe + pj >= 210)c=1;
    else if((pm + pe + pj >= 150) && (pm >= 80 || pe >= 80))c=1;
    else c=2;
    return c;
}

int main(void){
    int n,pm,pe,pj;
    while(scanf("%d",&n) != EOF && n != 0){
        for(int i=0;i < n;i++){
            scanf("%d %d %d",&pm,&pe,&pj);
            printf("%c\n",'A' + cjudge(pm,pe,pj));
        }
    }
    return 0;
}

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

C++: #include<stdio.h>
int main(void) {
	int n;
	int i,m,e,j;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			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>
using namespace std;

bool isA( int a, int b, int c )
{
    if ( a == 100 || b == 100 || c == 100 ) return true;
    if ( ( a + b ) / 2 >= 90 || ( a + b + c ) / 3 >= 90 ) return true;
    if ( ( a + b + c ) / 3 >= 80 ) return true;
    return false;
}

bool isB( int a, int b, int c )
{
    if ( ( a + b + c ) / 3 >= 70 ) return true;
    if ( ( a + b + c ) / 3 >= 50 && ( a >= 80 || b >= 80 ) ) return true;
    return false;
}

void printClass( int a, int b, int c )
{
    if ( isA( a, b, c ) ) cout << "A" << endl;
    else if ( isB( a, b, c ) ) cout << "B" << endl;
    else cout << "C" << endl;
}

int main( void )
{
    int n;

    while ( cin >> n && n )
    {
        int a, b, c;
        for ( int i = 0; i < n; i++ )
        {
            cin >> a >> b >> c;
            printClass( a, b, c );
        }
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int main() {
	
	int n;

	while (cin >> n && n != 0) {

		int grade[3];

		for (int i = 0; i < n; i++) {
			cin >> grade[0] >> grade[1] >> grade[2];

			if (grade[0] == 100 || grade[1] == 100 || grade[2] == 100)
				cout << "A\n";

			else if ((grade[0] + grade[1]) / 2 >= 90)
				cout << "A\n";

			else if ((grade[0] + grade[1] + grade[2]) / 3 >= 80)
				cout << "A\n";

			else if ((grade[0] + grade[1] + grade[2]) / 3 >= 70)
				cout << "B\n";

			else if ((grade[0] + grade[1] + grade[2]) / 3 >= 50 &&
				(grade[0] >= 80 || grade[1] >= 80))
				cout << "B\n";

			else
				cout << "C\n";
		}
	}

	return 0;

}

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

int main(){

  int n;

  while(cin >> n, n){

    int m,e,j;

    for(int i=0;i<n;i++){

      double ave,lank = 0,me;

      cin >> m >> e >> j;
      
      ave = m + e + j;
      ave /= 3;
      me = m + e;
      me /= 2;

      if(m == 100 || e == 100 || j == 100) lank = 3;

      

      if(lank != 3){
	if(me >= 90) lank = 3;
	else if(ave >= 80) lank = 3;
	else if(ave >= 70) lank = 2;
	else if(ave >= 50 && m >= 80 || e >= 80) lank = 2;
	else lank = 1;
      }

      if(lank == 3) cout << "A" << endl;
      else if(lank == 2) cout << "B" << endl;
      else cout << "C" << endl;

    }
  }
}

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){
				cls[i]=1;
				flg++;
			}
			if((m+e)/2>=90){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)/3>=80){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)/3>=70&&(m+e+j)/3<80){
				flg++;
				cls[i]=2;
			}
			if(((m+e+j)/3>=50&&(m+e+j)/3<80)&&((m>=80&&m<100)||(e>=80&&e<100))){
				flg++;
				cls[i]=2;
			}
			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<bits/stdc++.h>
using namespace std;
int main(){
  while(true){
    int n;
    cin>>n;
    if(!n) break;
    for(int i=0;i<n;++i){
      int m,e,j;
      cin>>m>>e>>j;
      if(m==100 || e==100 || j==100) cout<<"A"<<endl;
      else if((m+e)/2>=90) cout<<"A"<<endl;
      else if((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 || e>=80)) cout<<"B"<<endl;
      else cout<<"C"<<endl;
    }
  }
  return 0;
}

C++: #include <iostream>

char detClass(int pm, int pe, int pj)
{
	mean = (pm + pe + pj)/3;
	if((pm == 100) | (pe == 100) | (pj == 100)) {
		return 'A';
	} else if( (pm + pe)/2 >= 90) {
		return 'A';
	} else if( mean >= 80) {
		return 'A';
	} else if( mean >= 70) {
		return 'B';
	} else if( (mean >= 50) && ((pm >= 80) | (pe >= 80))) {
		return 'B';
	} else {
		return 'C';
	}
}

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