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 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)
{
    int n, pm, pe, pj;
    scanf("%d", &n);
    if (n != 0) {
        for (int i = 0; i < n; ++i) {
            scanf("%d %d %d", &pm, &pe, &pj);
            divide(pm, pe, pj);
        }
    }
    return 0;
}

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

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

C++: #include <stdio.h>

int grading(int pm, int pe, int pj);

int main(void)
{
    int number;
    int pm, pe, pj;
    scanf("%d", &number);// number of students to grade                                                                                                                              
    for (int j = 0; j < number; j++) {
      int grade;
      scanf("%d %d %d", &pm, &pe, &pj);
      grade = grading(pm, pe, pj);
      if (grade == 1) {// grade 1 means class A                                                                                                                                      
        printf("A\n");
      } else if (grade == 2) {//grade 2 means class B                                                                                                                                
        printf("B\n");
      } else if (grade == 3) {//grade 3 means class C                                                                                                                                
        printf("C\n");
      }
    }
    return 0;
}

int grading(int pm, int pe, int pj)
{
    int grade;
    if (pm == 100 || pe == 100 || pj == 100) {
      grade = 1;
      return grade;
    } else if ((pm + pe) / 2 >= 90) {
      grade = 1;
      return grade;
    } else if ((pm + pe + pj) / 3 >= 80) {
      grade = 1;
      return grade;
    } else if ((pm + pe + pj) / 3 >= 70) {
      grade = 2;
      return grade;
    } else if ((pm + pe + pj) / 3 >= 50 && (pm >=80 || pe >=80)) {
      grade = 2;
      return grade;
    } else {
      grade = 3;
      return grade;
    }
    return grade;
}

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

int main(){
  int n;

  while(1){
    cin >> n;
    if( n == 0) break;
    for(int i = 0; i < n; i++){
      int m,e,j;
      cin >> m >> e >> j;
      double a = (m+e+j)/3;
      cout << "average " << a << endl;

      if(m == 100 || e == 100 || j == 100){
	cout << "A" << endl;
      }
      else if( double((m+e))/2 >= 90){
	cout << "A" << endl;
      }
      else if(a >= 80 ){
	cout << "A" << endl;
      }
      else if(a >=70 ){
	cout << "B" << endl;
      }
      else if(a >=50 ){
	if(m >= 80 || e >= 80){
	  cout << "B" << endl;
	}
	else{
	  cout << "C" << endl;
	}
      }
      else{
	cout << "C" << endl;
      }
    }

  }


  return 0;
}

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

C++: #include <iostream>


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

C++: #include <cstdio>

int n;

main(){
  scanf("%d", &n);

  if(n==0) return 0;

  int m,e,j,s;
  while(n--){
    scanf("%d%d%d", &m, &e, &j);
    s = m+e+j;
    if(m == 100 || e == 100 || j == 100) puts("A");
    else if(m+e >= 180) puts("A");
    else if(s >= 240) puts("A");
    else if(s >= 210) puts("B");
    else if(s >= 150 && (m >= 80 || e >= 80)) puts("B");
    else puts("C");
  }

  main();
}