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 <iostream>
using namespace std;

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;
    int pm[n], pe[n], pj[n];
    double average[n];
    double ave_me[n];
    for(int i = 0; i < n; i++) {
      cin >> pm[i] >> pe[i] >> pj[i];
      average[i] = (pm[i]+pe[i]+pj[i])/3.0;
      ave_me[i] = (pm[i]+pe[i])/2.0;
    }
    char grade[n];
    for(int i = 0; i < n; i++) {
      if(pm[i] == 100 || pe[i] == 100 || pj[i] == 100) {
	grade[i] = 'A';
      } else if(ave_me[i] >= 90) {
	grade[i] = 'A';
      } else if(average[i] >= 80) {
	grade[i] = 'A';
      } else if(average[i] >= 70) {
	grade[i] = 'B';
      } else if(average[i] >= 50 && (pm[i] >= 80 || pe[i] >= 80)) {
	grade[i] = 'B';
      } else {
	grade[i] = 'C';
      }
      cout << grade[i] << endl;
    }
  }
  return 0;
}

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

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int n;
	cin >> n;
	if(n==0)break;
	REP(i,n){
	    double pm,pe,pj;
	    char ans;
	    cin >> pm >> pe >> pj;
	    double ave = (pm + pe + pj) / 3.0;
	    if(pm == 100 || pe == 100 || pj == 100){
		ans = 'A';
	    }else if(pm + pe >= 180){
		ans = 'A';
	    }else if(ave >= 80){
		ans = 'A';
	    }else if(ave >= 70){
		ans = 'B';
	    }else if(ave >= 50 && (pm >= 80 || pe >= 80)){
		ans = 'B';
	    }else ans = 'C';
	    cout << ans << endl;
	}
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
//#include <fstream>

using namespace std;

int main()
{
//	cut here before submit 
//	freostudent[i][1]n ("testcase.divstudent", "r", stdin );
	const char rank[] = { 'A', 'B', 'C' };
	int n;

	while (cin >> n && n ){
		vector <vector <int> > student(n, vector <int> (3, 0 ) );

		for (int i = 0; i < n; ++i){
			for (int j = 0; j < 3; ++j){
				cin >> student[i][j];
			} // end for
		} // end for


/*
100 _ÌÈÚª é	 A
wÆpêÌ½Ï_ª 90 _Èã	 A
3 ÈÚÌ½Ï_ª 80 _Èã	 A
3 ÈÚÌ½Ï_ª 70 _Èã	 B
3 ÈÚÌ½Ï_ª 50 _ÈãÅw©pêª 80 _Èã	 B
ãÌðð½³È¢	 C
¡Ìðð½·êÍAæèxÌ¢NXÉª¯çêÜ·B
*/
		for (int i = 0; i < n; ++i){ 	
			if (student[i][0] == 100 || student[i][1] == 100 || student[i][2] == 100){
				cout << rank[0] << endl;
				continue;
			} // end if
			if ((student[i][0] + student[i][1])/2. >= 90.0 ){
				cout << rank[0] << endl;
				continue;
			} // end if
			double avg = (student[i][0] + student[i][1] + student[i][2])/3.;
			if ( avg >= 80. ){
				cout << rank[0] << endl;
				continue;
			} // end if
			if ( avg >= 70. || (avg >= 50. && (student[i][0] >= 80 || student[i][1] >= 80 ) ) ){
				if ( avg >= 70. && (avg >= 50. && (student[i][0] >= 80 || student[i][1] >= 80 ) ) ) {
					cout << rank[0] << endl;
				}else{
					cout << rank[1] << endl;
				} // end if
				continue;
			} // end if
			cout << rank[2] << endl;
		} // end for
	} // end loop
		
	return 0;
}

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

int main() {
	// your code goes here
	int N;
	
	while(cin >> N && N){
		int m,e,j;
		for(int i=0;i<N;i++){
			cin >> m >> e >> j;
			if(max(m,max(e,j))==100 || (m+e)>=180 || m+e+j>= 240)
			cout <<"A" << endl;
			else if(m+e+j>=210 || (m+e+j>=150 && max(e,m)>=80))
			cout <<"B" << endl;
			else 
			cout << "C" << endl;
		}
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int pm,pe,pj,pa,cl;
  int i=0,l;
  char a[100000];
  
  while(cin>>cl!=0){
    l=i;
    for(int j=0;j<cl;j++){
      cin>>pm>>pe>>pj;
      pa=(pm+pe+pj)/3;
      if(pm==100||pe==100||pj==100||90<=(pm+pe)/2||80<=pa)a[i]='A';
      else if(70<=pa||80<=pe||80<=pm)a[i]='B';
      else a[i]='C';
      i++;
    }
    for(int j=l;j<i;j++)
      cout<<a[j]<<endl;
  }
  
  
  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--){
      double a, b, c;
      cin >> a >> b >> c;
      if (a == 100 or b == 100 or c == 100) cout << "A";
      else if ((a + b) / 2 >= 90) cout << "A";
      else if ((a + b + c) / 3 >= 80) cout << "A";
      else if ((a + b + c) / 3 >= 70) cout << "B";
      else if ((a + b + c) / 3 >= 50 && (a >= 80 or b >= 80)) cout << "B";
      else cout << "C";
      cout << endl;
    }
  }
}

C++: #include <stdio.h>

void divide(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
        printf("A\n");
    } else if (pm + pe >= 180) {
        printf("A\n");
    } else if (pm + pe + pj >= 240) {
        printf("A\n");
    } else if (pm + pe + pj >= 210) {
        printf("B\n");
    } else if (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80)) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

int main(void)
{
    while(1){
        int n, pm, pe, pj;
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            for (int i = 0; i < n; ++i) {
                scanf("%d %d %d", &pm, &pe, &pj);
                divide(pm, pe, pj);
            }
        }
    }
    return 0;
}

C++: #include <stdio.h>
int main(void)
{
	int suu,ei,koku;
	int x,y;
	int n;
	int i;

	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&suu,&koku,&ei);
			x=(suu+ei)/2;
			y=(suu+koku+ei)/3;
			if(suu==100 || koku==100 || ei==100){
				printf("A\n");
			}
			else if(x>=90){
				printf("A\n");
			}
			else if(y>=80){
				printf("A\n");
			}
			else if(y>=70){
				printf("B\n");
			}
			else if(y>=50 && (suu>=80 || ei>=80)){
				printf("B\n");
			}
			else{
				printf("C\n");
			}
		}
		scanf("%d",&n);
	}
	return 0;
}