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

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

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

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

int main(){
	int n,a,b,c;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 0; i < n; i++){
			scanf("%d %d %d",&a,&b,&c);
			if(a == 100 || b == 100 || c == 100 || a + b >= 180 || a+b+c >= 240){
				printf("A\n");
			}else if((a + b + c >= 210) || (a+b+c>=150 && (a >= 80 || b >= 80))){
				printf("B\n");
			}else{
				printf("C\n");
			}
		}

	}
    return 0;
}

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

using namespace std;

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

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

		for (int i = 0; i < n; ++i){
			for (int j = 0; j < 3; ++j){
				cin >> s[i][j];	// pm, pe, pj order
			} // 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){

			double me  = (s[i][0] + s[i][1])/2.;
			double avg = (s[i][0] + s[i][1] + s[i][2])/3.;
 	
			if ( s[i][0] == 100 || s[i][1] == 100 || s[i][2] == 100
			|| me >= 90.0 || avg >= 80. ) {
				cout << rank[0] << endl;
				continue;
			} // end if
			if ( avg >= 70. || (avg >= 50. && (s[i][0] >= 80 || s[i][1] >= 80 ) ) ) {
				cout << rank[1] << endl;
				continue;
			} // end if

			cout << rank[2] << endl;
		} // end for
	} // end loop
		
	return 0;
}

C++: #include <stdio.h>

void grade(int students)
{
    for(int i = 0; i < students; ++i) {
        int math, english, japanese;
        scanf("%d %d %d", &math, &english, &japanese);
        int mean = (math + english + japanese) / 3;
        if ((math == 100) || (english == 100) || (japanese == 100)) {
            printf("A\n");
        } else {
            if (((math + english) / 2 >= 90) || mean >= 80) {
                printf("A\n");
            } else if ((mean >= 70) || ((mean >= 50) && ((math >= 80) || (english >= 80)))) {
                printf("B\n");
            } else {
                printf("C\n");
            }
        }
    }
}

int main(void)
{
    int students;
    scanf("%d", &students);
    grade(students);
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  int s,i,a,b,c;
  while(cin>>s,s){
  while(s--){
    cin>>a>>b>>c;
    if(a==100||b==100||c==100||b+c>179||a+b+c>239)cout<<'A'<<endl;
    else if(a+b+c>209||(a+b+c>149&&(a>79||c>79)))cout<<'B'<<endl;
    else cout<<'C'<<endl;
  }}
}

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

int main(){
	int n,m,e,j;
	while(cin >> n,n){
		for(int i = 0;i < n;i++){
			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<iostream>
using namespace std;

int main() {
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		for (int b = 0; b < a; b++) {
			int d, e, f;
			cin >> d >> e >> f;
			if (d==100|| d==100 || d==100 || d + e > 179 || d + e + f > 239)cout << "A";
			else if ((d + e + f > 209) ||( (d + e + f > 149) && (d > 79 || e > 79)))cout << "B";
			else cout << "C";
			cout << endl;
		}
	}
}

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

C++: #include <stdio.h>

char dividing(int pm, int pe, int pj);

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

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

C++: #include<stdio.h>
#include<string.h>
int main(void)
{
	int a,s,d,f,g[10001],h,i,j;
	scanf("%d",&a);
	while(a!=0){
		for(i=1;i<=a;i++){
			scanf("%d %d %d",&s,&d,&f);
			if(s==100||d==100||f==100){
				g[i]=1;
			}
			else if((s+d)/2>=90){
				g[i]=1;
			}
			else if((s+d+f)/3>=80){
				g[i]=1;
			}
			else if((s+d+f)/3>=70){
				g[i]=2;
			}
			else if((s+d+f)/3>=50&&s>=80||d>=80){
				g[i]=2;
			}
			else{
				g[i]=3;
			}
		}
		for(i=1;i<=a;i++){
			if(g[i]==1){
				printf("A\n");
			}
			if(g[i]==2){
				printf("B\n");
			}
			if(g[i]==3){
				printf("C\n");
			}
		}
		scanf("%d",&a);
	}
	return 0;
}