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>

void grade(int students)
{
    while(students != 0) {
        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");
                }
            }
        }
        scanf("%d", &students);
    }
}

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

C++: #include<bits/stdc++.h>

using namespace std;

int main(){

  while(1){
	int n;
	
	cin >> n;
	
	if(n == 0)
	  break;
	
	vector<int> pm(n);
	vector<int> pe(n);
	vector<int> pj(n);
	
	for(int i=0;i<n;++i){
	  int sum=0;
	  cin >> pm[i] >> pe[i] >> pj[i];

	  sum = pm[i] + pe[i] + pj[i];
	  
	  if(pm[i] == 100 || pe[i] == 100 || pj[i] == 100)
		cout << "A" << endl;

	  else if(pm[i] + pe[i] >= 180)
		cout << "A" << endl;

	  else if(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;
	}
  
  }

}

C++: #include<stdio.h>
int main(void)
{
	int n,m,e,j,i,cls[10000],flg;
	while(1){
		scanf("%d",&n);
		if(n==0)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&&(m+e+j)/3<80){
				flg++;
				cls[i]=2;
			}
			if(((m+e+j)/3>=50&&(m+e+j)/3<80)&&((m>=80&&m<100)||(e>=80&&e<100))){
				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<iostream>
using namespace std;
int n, a, b, c;
int main() {
	while (true) {
		cin >> n; if (n == 0) { break; }
		for (int i = 0; i < n; i++) {
			cin >> a >> b >> c;
			if (a + b + c >= 240) { goto A; }
			if (a + b >= 180) { goto A; }
			if (a == 100 || b == 100 || c == 100) { goto A; }
			if (a + b + c >= 210) { goto B; }
			if (a + b + c >= 150 && (a == 80 || b == 80)) { goto B; }
			goto C;
		A:; cout << 'A' << endl; goto D;
		B:; cout << 'B' << endl; goto D;
		C:; cout << 'C' << endl; goto D;
		D:;
		}
	}
}

C++: #include <iostream>

char jukuClass(int, int, int);
int main()
{
    while (true) {
        int n;
        std::cin >> n;
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; ++i) {
            int pm, pe, pj;
            std::cin >> pm >> pe >> pj;
            std::cout << jukuClass(pm, pe, pj) << std::endl;
        }
    }
    return 0;
}
char jukuClass(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
        return 'A';
    } else if ((pm + pe) / 2.0 >= 90) {
        return 'A';
    } else if ((pm + pe + pj) / 3.0 >= 80) {
        return 'A';
    } else if ((pm + pe + pj) / 3.0 >= 70) {
        return 'B';
    } else if (((pm + pe + pj) / 3.0 >= 50) && (pm >= 80 || pe >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

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

	while (getline (cin, str ) ){
		stringstream ssn(str);
		ssn >> n;
		if (n == 0 ){
			break;
		} // end if
		int i;
		for (i = 0; i < n; ++i){
			int pm, pe, pj; 
			getline (cin, str );
			
			stringstream ss(str);
			ss >> pm >> pe >> pj;
/*
100 _ÌÈÚª é	 A
wÆpêÌ½Ï_ª 90 _Èã	 A
3 ÈÚÌ½Ï_ª 80 _Èã	 A
3 ÈÚÌ½Ï_ª 70 _Èã	 B
3 ÈÚÌ½Ï_ª 50 _ÈãÅw©pêª 80 _Èã	 B
ãÌðð½³È¢	 C
¡Ìðð½·êÍAæèxÌ¢NXÉª¯çêÜ·B
*/
			if (pm == 100 || pe == 100 || pj == 100){
				cout << rank[0] << endl;
				continue;
			} // end if
			if ((pm + pe)/2. >= 90.0 ){
				cout << rank[0] << endl;
				continue;
			} // end if
			double avg = (pm + pe + pj)/3.;
			if ( avg >= 80. ){
				cout << rank[0] << endl;
				continue;
			} // end if
			if ( avg >= 70. || (avg >= 50. && (pm >= 80 || pe >= 80 ) ) ){
				if ( avg >= 70. && (avg >= 50. && (pm >= 80 || pe >= 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 <stdio.h>

int main(void)
{
    int number, pm, pe, pj, temp;
    while(1){
        scanf("%d", &number);
        for (int i = number; i > 0; i--){
            scanf("%d %d %d", &pm, &pe, &pj);
            if (pm == 100|| pe == 100|| pj == 100|| (pe + pm)/2 >= 90||(pe + pm + pj)/3 >= 80 ){
                printf("A\n");
            }else if((pe + pm + pj)/3 >= 70||((pe + pm + pj)/3 >= 50 && (pe >= 80|| pm >= 80))) {
                printf("B\n");
            }else{
                printf("C\n");          
            }
        }
    }
    return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n,m,e,j;
    char z;
    while(true){
    cin>>n;
    if(n==0)
        break;
    for(int i=0;i<n;i++){
        cin>>m>>e>>j;
        z='C';
        if(m+e+j>=210)
            z='B';
        if(m+e+j>=150&&(m>=80||e>=80))
            z='B';
        if(m==100||e==100||j==100)
            z='A';
        if(m+e>=180)
            z='A';
        if(m+e+j>=240)
            z='A';
        cout<<z<<endl;
    }
    }
    return 0;
}

C++: #include <stdio.h>

int classjudge(int pm,int pe,int pj){
    int class;
    if(pm == 100 || pe== 100 || pj== 100){
        class=0;
    }
    else if(pm + pe >= 180){
        class=0;
    }
    else if(pm + pe + pj >= 240){
        class=0;
    }
    else if(pm + pe + pj >= 210){
        class=1;
    }
    else if((pm + pe + pj >= 150) && (pm >= 80 || pe >= 80)){
        class=1;
    }
    else class=2;
    return class;
}

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