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<cstdio>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n),n){
        int m[10010],e[10010],j[10010];
        char ans[10010] = {0};
        for(int i = 0;i < n; i++){
            scanf("%d%d%d",&m[i],&e[i],&j[i]);
            if(m[i] == 100 || e[i] == 100 || j[i] == 100)ans[i] = 'A';
            else if((m[i]+e[i])/2 >= 90)ans[i] = 'A';
            else if((m[i]+e[i]+j[i])/3 >= 80)ans[i] = 'A';
            else if((m[i]+e[i]+j[i])/3 >= 70)ans[i] = 'B';
            else if((m[i]+e[i]+j[i])/3 >= 50 && e[i] >= 80)ans[i] = 'B';
            else if((m[i]+e[i]+j[i])/3 >= 50 && m[i] >= 80)ans[i] = 'B';
            else ans[i] = 'C';
        }
        for(int i = 0;i < n; i++)printf("%c\n",ans[i]);
    }
    return 0;
}

C++: #include <stdio.h>

int main(void){
	int n;
	int pm, pe, pj;
	double avr;
	
	while (scanf("%d", &n), n){
		for (int i=0; i<n; i++){
			scanf("%d %d %d", &pm, &pe, &pj);
			avr = (pm+pe+pj)/3.;
			if (pm==100 || pe==100 || pj==100){
				puts("A");
			} else if (pm+pe >= 180){
				puts("A");
			} else if (avr>=80){
				puts("A");
			} else if (avr >= 70){
				puts("B");
			} else if (avr >= 50 && (pm>=80 || pe >= 80)){
				puts("B");
			} else {
				puts("C");
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>

int main(){
	int n,pm,pe,pj;
	int i;
	char grade;

	while(scanf("%d",&n),n){

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

	return 0;
}

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

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{

		rep(i,n)
		{
	   		double	pm,pe,pj;
			cin >> pm >> pe >> pj;


			if(pm >= 100 || pe >= 100 || pj >= 100)
			{
				cout << "A" << endl;
			}
			else
			{
				double temp = pm + pe;
				temp /= 2;

		   		double temp2 = pm + pe + pj;
				temp2 /= 3;

				if(temp >= 80)
				{
					cout << "A" << endl;
				}
				else if(temp2 >= 70)
				{
					cout << "B" << endl;
				}
				else if(temp2 >= 50 && (pm >= 80 || pe >= 80))
				{
					cout << "B" << endl;
				}
				else cout << "C" << endl;
			}	
		}
	}
}

C++: #include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (long u = 0; u < 1000; u++)
	{
		int a[10001],b[10001],c[10001];
		long n;

		cin >> n;
		if (n == 0)
		{
			break;
		}

		for (int i = 0; i < n; i++)
		{
			cin >> a[i] >> b[i] >> c[i];
		}

		int p = 0;

		for (int i = 0; i < n; i++)
		{
			p = (a[i] + b[i] + c[i]) / 3;
			if (a[i] == 100 || b[i] == 100)
			{
				cout << 'A' << endl;
			}
			else if (c[i] == 100)
			{
				cout << 'A' << endl;
			}
			else if ((a[i] + b[i]) / 2 >= 90)
			{
				cout << 'A' << endl;
			}
			else if (p >= 80)
			{
				cout << 'A' << endl;
			}
			else if (p >= 70)
			{
				cout << 'B' << endl;
			}
			else if (p >= 50 && a[i] >= 80)
			{
				cout << 'B' << endl;
			}
			else if (p >= 50 && b[i] >= 80)
			{
				cout << 'B' << endl;
			}
			else
			{
				cout << 'C' << endl;
			}
		}
	}
}

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

int main(){
  int n;
  cin >> n;
 
  while(n>0){
	int pm[n],pe[n],pj[n];
	int hei[n],me[n];
	string student[n];
	for(int i=0;i<n;i++){
		cin >> pm[i] >> pe[i] >> pj[i];
		hei[i]=(pm[i]+pe[i]+pj[i])/3;
		me[i]=(pm[i]+pe[i])/2;
	}
	for(int i=0;i<n;i++){
		if(pm[i]==100||pe[i]==100||pj[i]==100)
			student[i]="A";
		else if(me[i]>=90)
			student[i]="A";
		else if(hei[i]>=80)
			student[i]="A";
		else if(hei[i]>=70)
			student[i]="B";
		else if(hei[i]>=50&&(pm[i]>=80||pe[i]>=80))
			student[i]="B";
		else
			student[i]="C";
	}

	for(int i=0;i<n;i++){
		cout << student[i] << endl;
	}

	cin >> n;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
 
int main(){
	int n,pm,pe,pj;
	
	while(cin >> n,n){
		for(int i=0;i<n;i++){
			cin >> pm >> pe >> pj;
			
			double me=(pm+pe)/2;
			double avg=(pm+pe+pj)/3;
			
			if(pm==100||pe==100||pj==100||me>=90||avg>=80){
				cout << "A" << endl;
			}
			else if(avg>=70||avg>=50&&(pm>=80||pe>=80)){
				cout << "B" << endl;
			}
			else cout << "C" << endl;
		}
	}
  return 0;
}

C++: #include <stdio.h>

char dividing(int pm, int pe, int pj);

int main(void)
{
    while (1) {
        int number;
        scanf("%d", &number);
        if (number == 0) {
            break;
        } else {
            for (int i = 0; i < number; i++) {
                int pm, pe, pj;
                scanf("%d %d %d", &pm, &pe, &pj);
                printf("%c\n", dividing(pm, pe, pj));
            }
        }
    }
}

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

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

void res(int,int,int);

int main(void){
  int n,pm,pe,pj;

  for(;;){  
    cin >> n;
    if( n == 0 ) break;

    for( int i = 0 ; i < n ; i++ ){
      cin >> pm >> pe >> pj;
      res(pm,pe,pj);
    }
  }
  
  return 0;
}

void res(int pm,int pe,int pj){
  double ave,meave;

  ave = (double)(pm+pe+pj) / 3;
  meave = (double)(pm+pe) / 2;

  if( pm == 100 || pe == 100 || pj == 100 || meave >= 90 || ave >= 80 )
    cout << 'A' << endl;
  else if( ave >= 70 || ( ave >= 50 && ( pm >= 80 || pe >= 80 )))
    cout << 'B' << endl;
  else cout << 'C' << endl;

}

C++: #include<stdio.h>

int grade(int pm, int pe, int pj)
{   
    int t;
    int sum = pm + pe +pj;
    if ((pm == 100) || (pe == 100) || (pj == 100)) {
        t = 0;
    } else if (pm + pe >= 180) {
        t = 0;
    } else if (sum >= 240) {
        t = 0;
    } else if (sum >= 210) {
        t = 1;
    } else if ((sum >= 150) && ((pe >= 80) || (pm >= 80))) {
        t = 1;
    } else {
        t = 2;
    } 
    return t;
}
    
        
int main(void)
{
    int n;
    while(1) {
        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);
                int t = grade(pm, pe, pj);
                if (t == 0) {
                    printf("A\n");
                } else if (t == 1) {
                    printf("B\n");
                } else {
                    printf("C\n");
                }
            }
        }
    }
    return 0;
}