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>
char classify(int pm, int pe, int pj);

int main(void)
{
    int n, pm, pe, pj;
    scanf("%d", &n);
    for (int i = 0;i < n;i ++){
	scanf("%d %d %d", &pm, &pe, &pj); 
	printf("%c\n", classify(pm, pe, pj));
    }
    return 0;
}

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    for (int i = 0; i < n; i++) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      char ans = 'C';
      if (pm == 100 || pe == 100 || pj == 100) ans = 'A';
      else if (pm + pe >= 180) ans = 'A';
      else if (pm + pe + pj >= 240) ans = 'A';
      else if (pm + pe + pj >= 210) ans = 'B';
      else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)) ans = 'B';
      cout << ans << 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)/3;
			
			if(pm==100 || pe==100 || pj==100)cout<<"A";
			else if((pm+pe)/2>=80)cout<<"A";
			else if(avr>=80)cout<<"A";
			else if(avr>=70)cout<<"B";
			else if(avr>=50 && (pm>=80||pe>=80))cout<<"B";
			else cout<<"C";
			
			cout<<endl;
		}
	}
	return 0;
}

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

int main(){

int N,M,K,R;
double ave=0,S=0,aav=0;
while(1){
cin>>N;if(N==0)break;
for(int i=0;i<N;i++){
cin>>M>>R>>K;
S=M+R+K;ave=S/3;aav=(M+R)/2;
if(aav>=90)printf("A\n");
else if(ave>=80)printf("A\n");
else if(M==100||R==100||K==100)printf("A\n");
else if(ave>=70)printf("B\n");
else if(ave>=50){if(M>=80||R>=80)printf("B\n");
else printf("C\n");}
else printf("C\n");
}
ave=0,S=0,aav=0;
}
return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include <iostream>
using namespace std;
int main(){
	int n,pe,pj,pm;
	cin>>n;
	while(n)
		for(int i=0; i<=n; i++){
			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((pe+pm+pj)/3>=80){
				cout<<"A"<<endl;
			}else if((pe+pj+pm)/3>=70){
				cout<<"B"<<endl;
			}else if((pe+pj+pm)/3>=50||pm>=80&&pe>=80){
				cout<<"B"<<endl;
			}else if((pe+pj+pm)/3>50){
				cout<<"C"<<endl;
			}
		}
}

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

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

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int a,a1,a2,a3,i,sum=0,avg=0;
	while(1){
		cin>>a;
		if(a==0) break;
		for(i=0;i<a;i++){
			cin>>a1>>a2>>a3;
			sum=a1+a2+a3;
			avg=sum/3;
			if(a1==100||a2==100||a3==100||avg>=80||(a1+a2)/2>=90||avg>=50&&a1>=80&&a2>=80||avg>=70&&a1>=80||avg>=70&&a2>=80)
				printf("A\n");
			else if(avg>=70||avg>=50&&a1>=80||avg>=50&&a2>=80)
				printf("B\n");
			else
				printf("C\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 sum = pm + pe + pj;
      if ((max(pm, max(pe, pj)) == 100) || (pm + pe) / 2 >= 90 || (sum / 3) >= 80){
        cout << 'A';
      }
      else if (sum / 3 >= 70 || (sum / 3 >= 50 && max(pm, pe) >= 80)){
        cout << 'B';
      } 
      else {
        cout << 'C';
      }
      cout << endl;
    }
  }
  return (0);
}

C++: #include<iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int pm,pe,pj;
		if(n==0)break;
		for(int i=0;i<n;i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||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>=80||pe>=80){
				cout<<"B"<<endl;
			}else{
				cout<<"C"<<endl;
			}
		}
	}
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int a,b,i;
	while(1){
	scanf("%d",&a);
	if(a==-1) break;
	b=0;
	if(a<=10){
	b=1150;
	}
	else if(a<=20){
	b=1150;
	for(i=0;i<a-10;i++){
	b+=125;
	}
	}
	else if(a<=30){
	b=2400;
	for(i=0;i<a-20;i++){
	b+=140;
	}
	}
	else if(a>30){
	b=3800;
	for(i=0;i<a-30;i++){
	b+=160;
	}
	}
	printf("%d\n",4280-b);
	}
	return 0;
	}

C++: #include <iostream>
using namespace std;
 
int main(){
	int n,pm,pe,pj;
	
	while(cin >> n,n){
		for(int i=1;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;
			pm,pe,pj=0;
		}
	}
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,pm,pj,pe;
	while(n){
		cin>>n;
		for( int i=0; i<n; i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pj==100||pe==100){
				cout<<"A"<<endl;
			}else if((pm+pe)/2>=90){
				cout<<"A"<<endl;
			}else if((pm+pj+pe)/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;
}