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>

void dividing_student(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100 || ((pm + pe) / 2 >= 90) || ((pm + pe + pj) / 3 >= 80)) {
        printf("A\n");
    }
    else if (((pm + pe + pj) / 3 >= 70) || (((pm + pe + pj) / 3 >= 50) && (pm >=80 || pe >= 80))) {
        printf("B\n");
    }
    else {
        printf("C\n");
    }
}

int main(void)
{
    int n, pm, pe, pj;
    scanf("%d", &n);
    while (n != 0) {
        for (int i = 0; i < n; ++i) {
            scanf("%d %d %d", &pm, &pe, &pj);
            dividing_student(pm, pe, pj);
        }    
        scanf("%d", &n);
    }
    return 0;
}

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

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

C++: #include <stdio.h>

void judge(int pm, int pe, int pj)
{
    char class;

    if (pm == 100 || pe == 100 || pj == 100){
        class = 'A';
    } else if (pm + pe >= 180){
        class = 'A';
    } else if (pm + pe + pj >= 240){
        class = 'A';
    } else if (pm + pe + pj >= 210){
        class = 'B';
    } else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)){
        class = 'B';
    } else {
        class = 'C';
    }

    printf("%c\n", class);
}

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

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &pm, &pe, &pj);
                judge(pm, pe, pj);
            }
        }
    }

    return 0;
}

C++: #include <cstdio>
#include <iostream>

using namespace std;

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

	while (scanf("%d", &n), n != 0){
		for (int i = 0; i < n; i++){
			scanf("%d%d%d", &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 && (pm >= 80 || pe >= 80)){
				cout << "B" << endl;
			}
			else {
				cout << "C" << endl;
			}
		}
	}

	return (0);
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n;

char student[10010];

double cal(int m,int e,int j)
{
	double ave = (double)(m + e + j) / 3;

	return ave;
}

int main(void)
{
	while (cin >> n, n)
	{
		for (int i = 0; i < n; i++)
		{
			int m, e, j;

			cin >> m >> e >> j;

			if (m==100||e==100||j==100)
			{
				student[i] = 'A';

				continue;
			}
			if (((double)(m+e)/2)>=90)
			{
				student[i] = 'A';

				continue;
			}

			if (cal(m,e,j)>=80)
			{
				student[i] = 'A';

				continue;
			}

			if (cal(m, e, j) >= 70)
			{
				student[i] = 'B';

				continue;
			}

			if (cal(m, e, j) >= 50)
			{
				if (m>=80||e>=80)
				{
					student[i] = 'B';

					continue;
				}
			}

			student[i] = 'C';

		}

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

C++: #include <bits/stdc++.h>
#define endl    '\n'
using namespace std;

typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    int ma, en, ja, avg;
    char cls;

    cin >> n;

    while (n != 0) {
        for (int i = 0; i < n; ++i) {
            cin >> ma >> en >> ja;
            avg = (ma + en + ja) / 3;

            if (ma == 100 || en == 100 || ja == 100 || (ma + en) / 2 >= 90 || avg >= 80) {
                cls = 'A';
            } else if (avg >= 70 || avg >= 50 && (ma >= 80 || en >= 80)) {
                cls = 'B';
            } else {
                cls = 'C';
            }

            cout << cls << endl;
        }

        cin >> n;
    }

    return 0;
}

C++: // 2013/09/17 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int pm, pe, pj;
			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 && (pm>=80 || pe>=80)){
				cout << 'B' << endl;
			}
			else{
				cout << 'C' << endl;
			}
		}
        }

	return 0;
}

C++: #include <stdio.h>

int dividing(int math, int english, int japanese)
{
	if (math == 100 || english == 100 || japanese == 100) {
		printf("A\n");
	}else if (math + english >= 180) {
		printf("A\n");
	}else if (math + english + japanese >= 240) {
		printf("A\n");
	} else if (math + english + japanese >= 210) {
		printf("B\n");
	} else if (math + english + japanese >= 150 && math >= 80) {
		printf("B\n");
	} else if (math + english + japanese >= 150 && english >= 80) {
		printf("B\n");
	} else {
		printf("C\n");
	}
	return 0;
}

int main(void)
{
	int number;
	scanf("%d", &number);
	for (int i = 0; i < number; i++) {
		int math;
		int english;
		int japanese;
		scanf("%d %d %d", &math, &english, &japanese);
		dividing(math, english, japanese);
	}
}