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>
int main(void)
{
    int n,pm,pe,pj,i,s,d;
	while(1){
	    scanf("%d",&n);
	    if (n==0) {
    		break;
		}
		else {
			for (i=0;i<n;i++){
				scanf("%d %d %d",&pm,&pe,&pj);
				s=pm+pe;
				d=pm+pe+pj;
				if (pm>=100||pe>=100||pj>=100){
					printf("A\n");
				}
				else if (s>=180||d>=240){
					printf("A\n");
				}
				else if (d>=210){
					printf("B\n");
				}
				else if (d>=150&&(pm>=80||pe>=80)){
					printf("B\n");
				}
				else {
					printf("C\n");
				}
			}
			return 0;
		}
	}
}

C++: #include <iostream>

bool judgement_1(int a, int b, int c)
{
	if (a == 100 || b == 100 || c == 100 || a+b == 180 || a+b+c >= 240) {
		return true;
	} else {
		return false;
	}
}

bool judgement_2(int a, int b, int c)
{
	if (a+b+c >= 210 || (a+b+c >= 150 && (a == 80 || b == 80) )) {
		return true;
	} else {
		return false;
	}
}

int main()
{
    int x;
	int y;
    int z;
	bool flag[2];
	int n;
	std::cin >> n;
	while (n > 0) {
	    std::cin >> x >> y >> z;
	    flag[0] = judgement_1(x, y, z);
	    flag[1] = judgement_2(x, y, z);
	    if (flag[0]) {
	    	std::cout << "A" << std::endl;
	    } else if (flag[1]) {
	    	std::cout << "B" << std::endl;
	    } else {
	    	std::cout << "C" << std::endl;
	    n --;
	   }
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
	for(int n;cin>>n,n;){
		while(n--){
			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))
				cout<<'B'<<endl;
			else
				cout<<'C'<<endl;
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	while(1){
		int n;
		cin>>n;
		if(n==0) return 0;
		for(int i=0;i<n;i++){
			int a,b,c;
			cin>>a>>b>>c;
			if(a==100||b==100||c==100) cout<<"A"<<endl;
			else if(a+b>=180||a+b+c>=240) cout<<"A"<<endl;
			else if(a+b+c>=210) cout<<"B"<<endl;
			else if(a+b+c>=150&&(a>=80||b>=80)) cout<<"B"<<endl;
			else cout<<"C"<<endl;
		}
	}
}

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

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

	

}

C++: #include<iostream>
using namespace std;
int main(){
  int n,test[10000][3],A[10000]={0},B[10000]={0},C[10000]={0};
  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
	cin >> test[i][j];
      }
      if(test[i][0]==100 || test[i][1]==100 || test[i][2]==100){
	A[i]++;
      }
      else if((test[i][0]+test[i][1])/2>=90){
	A[i]++;
      }
      else if((test[i][0]+test[i][1]+test[i][2])/3>=80){
	A[i]++;
      }
      else if((test[i][0]+test[i][1]+test[i][2])/3>=70){
	B[i]++;
      }
      else if((test[i][0]+test[i][1]+test[i][2])/3>=50){
	if(test[i][0]>=80 || test[i][0]>=80){
	  B[i]++;
	}
      }
      else{
	C[i]++;
      }
    }
    for(int i=0;i<n;i++){
      if(A[i]!=0){
	cout << "A" << endl;
      }
      else if(B[i]!=0){
	cout << "B" << endl;
      }
      else/* if(C[i]!=0)*/{
	cout << "C" << endl;
      }
    }
    for(int i=0;i<n;i++){
      A[i]=0;
      B[i]=0;
      C[i]=0;
    }
  }
}

C++: #include <iostream>
using namespace std;
char judge(int a,int b,int c)
{
	if(a==100||b==100||c==100)return 'A';
	if(a+b>=180)return 'A';
	if(a+b+c>=240)return 'A';
	if(a+b+c>=210)return 'B';
	if((a+b+c>=150)&&(a>=80||b>=80))return 'B';
	return 'C';
}
int main()
{
	while(1)
	{
		int n;
		cin >> n;
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			int a,b,c;
			cin >> a >> b >> c;
			cout << judge(a,b,c) << endl;
		}
	}
	return 0;
}

C++: 
#include <iostream>

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

C++: #include <stdio.h>

void Hantei(int p[3])
{
  int flg=0;
  int sum=p[0]+p[1]+p[2];
  if(p[0]==100 || p[1]==100 || p[2]==100)
    {
      printf("A\n");
      return;
    }
  if((p[0]+p[1])>=180)
    {
      printf("A\n");
      return;
    }
  if(sum>=240)
    {
      printf("A\n");
      return;
    }
  if(sum>=210)
    {
      flg++;
    }
  if(sum>=150 && (p[0]>=80 || p[1]>=80))
    {
      flg++;
    }
  if(flg==2)
    {
      printf("A\n");
      return;
    }
  if(flg==1)
    {
      printf("B\n");
      return ;
    }

  printf("C\n");
}

int main(void)
{
  while(1)
    {
      int n;
      
      scanf("%d",&n);

      if(n==0)
	{
	  break;
	}

      int p[n][3];

      for(int i=0;i<n;i++)
	{
	  scanf("%d %d %d",&p[i][0],&p[i][1],&p[i][2]);
	}

      for(int i=0;i<n;i++)
	{
	  Hantei(p[i]);
	}
    }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int pm[10010],pe[10010],pj[10010];
    char result[10010];
    cin>>n;
    while( n!=0 ){
        for(int i=0;i<n;i++){
            cin>>pm[i]>>pe[i]>>pj[i];
        }
        for(int i=0;i<n;i++){
            if(pm[i]==100 || pe[i]==100 || pj[i]==100){
                result[i]='A';
            }else if( (pm[i]+pe[i])/2 >= 90){
                result[i]='A';
            }else if( (pm[i]+pe[i]+pj[i])/3 >= 80){
                result[i]='A';
            }else if( (pm[i]+pe[i]+pj[i])/3 >= 70){
                result[i]='B';
            }else if( (pm[i]+pe[i]+pj[i])/3 >= 50 && (pm[i] >= 80 || pe[i] >= 80)){
                result[i]='B';
            }else{
                result[i]='C';
            }
        }
        for(int i=0;i<n;i++){
            cout<<result[i]<<"\n";
        }
        cin>>n;
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

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

int main()
{
  int n;
  while (cin >> n, n){
    while (n--){
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      if (pm == 100 or pe == 100 or pj == 100) cout << "A";
      else if ((pm + pe) / 2 >= 90) cout << "A";
      else if ((pm + pe + pj) / 3 >= 80) cout << "A";
      else if ((pm + pe + pj) / 3 >= 70) cout << "B";
      else if ((pm + pe + pj) / 3 >= 50){
        if (pm >= 80) cout << "B";
        else if (pe >= 80) cout << "B";
      }
      if ((pm + pe + pj) / 3 < 70) cout << "C";
      cout << endl;
    }
  }
}