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 <bits/stdc++.h>
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>=180) {
                cout << 'A' << endl;
            }
            else if (pm+pe+pj>=240) {
                cout << 'A' << endl;
            }
            else if (pm+pe+pj>=210) {
                cout << 'B' << endl;
            }
            else if (pm+pe+pj>=150 && (pm>=80 || pe>=80)) {
                cout << 'B' << endl;
            }
            else {
                cout << 'C' << endl;
            }
        }
    }
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
  int n, m, e, j;

  while(1){
    cin >> n;
    if(n == 0){
      break;
    }
    for(int i = 0; i < n; i++){
      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>
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,pe,pj == 100 || (pm + pe) / 2 >= 90 || (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,pe >= 80){
				cout << "B" << endl;
		}
			else{
				cout << "C" << endl;
		}
	}
}

C++: #include <stdio.h>

float mean2(int x, int y)
{
    return (float)(x + y) / 2.0;
}

float mean3(int x, int y, int z)
{
    return (float)(x + y + z) / 3.0;
}

char grading(int p_math, int p_eng, int p_jpn)
{
    if ( p_math == 100 || p_eng == 100 || p_jpn == 100) {
        return 'A';
    } else if (mean2(p_math, p_jpn) >= 90.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 80.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0) {
        return 'B';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0 && (p_math >= 80 || p_eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    int i, p_math, p_eng, p_jpn, n_iteration;
    char grade;

    scanf("%d", &n_iteration);

    for (i = 0; i < n_iteration; i++) {
        scanf("%d %d %d", &p_math, &p_eng, &p_jpn);
        grade = grading(p_math, p_eng, p_jpn);
        printf("%c\n", grade);
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

void solve()
{
	int n;
	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) || (m + e >= 180) || (m + e + j >= 240))
			{
				cout << "A" << endl;
			}
			else if((m + e + j >= 210) || (m + e + j >= 150 && (m < 80 && e >= 80) || (m >= 80 && e < 80)))
			{
				cout << "B" << endl;
			}
			else
			{
				cout << "C" << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <stdio.h>
#include <stdbool.h>

void dividing_student (void)
{ 
    int math, english, japanese;
    scanf("%d %d %d", &math, &english, &japanese);
    if (math == 100 || english == 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 || english >= 80)) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

int main(void)
{
    while (true) {
        int n;
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        int i;
        for (i = 0; i < n; ++i) {
            dividing_student();
        }
    }
    return 0;
}

C++: #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,pe,pj == 100 || (pm + pe) / 2 >= 90 || (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,pe >= 80){
				cout << "B" << endl;
		}
			else{
				cout << "C" << endl;
		}
		}
	}
}

C++: #include<bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

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

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

int main() {
	int n,pm,pe,pj;
	while(cin>>n,n){
		for(;n;--n){
			cin>>pm>>pe>>pj;
			
			int avr = pm+pe+pj;
			
			if(pm==100 || pe==100 || pj==100)cout<<"A";
			else if(pm+pe>=180)cout<<"A";
			else if(avr>=240)cout<<"A";
			else if(avr>=210)cout<<"B";
			else if(avr>=150 && (pm>=80||pe>=80))cout<<"B";
			else cout<<"C";
			
			cout<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

double average(int a,int b,int c){
	return ((double)a+(double)b+(double)c)/3.0;
}
int main(){
	int n;
	while(cin>>n,n){
		int pe,pm,pj;
		char cls[n];
		rep(i,n){
			cin>>pm>>pe>>pj;
			if(pm==100 || pe==100 || pj==100)cls[i]='A';
			else if(average(pm,pe,pj)>=80 ||((double)pm+(double)pe)/2>=90)cls[i]='A';
			else if(average(pm,pe,pj)>=70 || (average(pm,pe,pj)>=50 && (pm>=80 || pe>=80)))cls[i]='B';
			else cls[i]='C';
		}
		rep(i,n)cout<<cls[i]<<endl;
	}
	return 0;
}

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

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