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>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;
  
int main(){
    /*??£???????????????????????????
            int a[2];
            cin >> a[1] >> a[2];
            cout << "[+] " << a[1] + a[2] << endl;
            cout << "[-] " << a[1] - a[2] << endl;
            cout << "[*] " << a[1] * a[2] << endl;
            cout << "[/] " << a[1] / a[2] << endl;
    */

    int a;
    while(cin >> a){
        if(a == 0){break;}
        int p[a][3],ave,ave2;
        for (int i = 1; i <= a; i++)
        {
            string ans;
            cin >> p[i][0] >> p[i][1] >> p[i][2]; 
            ave = ( p[i][0] + p[i][1] + p[i][2] ) / 3;
            ave2 = ( p[i][0] + p[i][1] ) / 2;            
            if(p[i][0]  >= 100 or p[i][1]  >= 100 or p[i][2]  >= 100){ans = "A";
            }else if(ave >= 80 or ave2 >= 90){
                ans = "A";
            }else if(ave >= 70){
                ans = "B";
            }else if(ave >= 50){
                if(p[i][0] >= 80 or p[i][1] >= 80){
                    ans = "B";
                }else{
                    ans = "C";
                } 
            }else{
                ans = "C";  
            }
            cout << ans << endl;
        }

    }
}

C++: #include<stdio.h>

void devide(int x, int y, int z)
{
    if((x == 100) || (y == 100) || (z == 100)) {
        printf("A\n");
    } else if ((x + y) >= 90*2) {
        printf("A\n");
    } else if ((x + y + z) >= 80*3) {
        printf("A\n");
    } else if ((x + y + z) >= 70*3) {
        printf("B\n");
    } else if ((x + y + z) >= 50*3) {
        if ((x >= 80) || (y >= 80)){
            printf("B\n");
        } else {
            printf("C\n");
        }
    } else {
        printf("C\n");
    }
}

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

    scanf("%d", &num);

    while (num != 0) {
        for (int i = 0; i < num; i++) {
            scanf("%d %d %d", &pm, &pe, &pj);
            devide(pm, pe, pj);
        }

        scanf("%d", &num);
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main() {
	int n, a, b, c;
	vector<char>l;
	while (true){
		cin >> n;
		if (n == 0){
			break;
		}
		else{
			for (int i = 0; i < n; i++){
				cin >> a >> b >> c;
				cout << a <<' '<< b <<' '<< c <<' '<< endl;
				if (a == 100 || b == 100 || c == 100){
					l.push_back('A');
				}
				else if (a + b >= 180){
					l.push_back('A');
				}
				else if (a + b + c >= 240){
					l.push_back('A');
				}
				else if (a + b + c >= 210){
					l.push_back('B');
				}
				else if (a + b + c >= 150 && a >= 80){
					l.push_back('B');
				}
				else if (a + b + c >= 150 && b >= 80){
					l.push_back('B');
				}
				else l.push_back('C');
				a = 0;
				b = 0;
				c = 0;
			}
		}
	}
	for (int i = 0; i != l.size(); i++)
	{
		cout << l[i] << endl;
	}
	char f;
	cin >> f;
}

C++: #include <stdio.h>
int pa(void)
{
    printf("A\n");
}

int pb(void)
{
    printf("B\n");
}

int pc(void)
{
    printf("C\n");
}

int main(void)
{
    int n, i,sum, pm[10000], pj[10000], pe[10000];
    while(1) {
	scanf("%d", &n);
	if (n == 0) {
	    break;
	}
	sum = pm[i] + pe[i] + pj[i];
	for (i = 0; i < n; i++) {
	    scanf("%d %d %d", &pm[i], &pj[i], &pe[i]);
	    if (pm[i] == 100 || pj[i] == 100 || pe[i] == 100) {
		pa();
	    } else if (pm[i] + pe[i] >= 90) {
		pa();
	    } else if (sum >= 240) {
		pa();
	    } else if (sum >= 210) {
		pb();
	    } else if (sum >= 150 && (pm[i] >= 80 || pe[i] >= 80)) {
		pb();
	    } else {
		pc();
	    }
	}
    }
    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<1)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){
				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<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<stdio.h>
 
int main(){
    int n, a, b, c, i , ans;
    while(scanf("%d", &n) != 0){
        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;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n,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||(pe+pm)/2>=90||(pe+pm+pj)/3>=80){
	cout<<'A'<<endl;
      }
      else if((pe+pm+pj)/3>=70||((pe+pm+pj)/3>=50&&(pe==80||pm==80))){
	cout<<'B'<<endl;
      }
      else{
	cout<<'C'<<endl;
      }
    }
  }
}

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 su,ei,ko;
      cin >> su >> ei >> ko;

      if(su == 100 || ei == 100 || ko == 100){
	cout << "A\n";
	continue; 
      }
      if((double)(su + ei)/2.0 >= 90.0){
	cout << "A\n";
	continue; 
      }
      if((double)(su + ei + ko)/3.0 >= 80.0){
	cout << "A\n";
	continue; 
      }
      if((double)(su + ei + ko)/3.0 >= 70.0){
	cout << "B\n";
	continue; 
      }
      if((double)(su + ei + ko)/3.0 >= 50.0 && (su >=80 || ei >= 80) ){
	cout << "B\n";
	continue; 
      }
      cout << "C\n";
    }


  }



}