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() {
	int n;
	while (cin >> n, n) {
		for (int i = 0;i < n;i++) {
			int m, e, j;
			int flg;
			cin >> m >> e >> j;
			if (m == 100 || e == 100 || j == 100)flg = 1;
			else if (m + e + j >= 240)flg = 1;
			else if (m + e >= 180)flg = 1;
			else if (m + e + j >= 210)flg = 0;
			else if (m + e + j >= 150 && (m >= 80 || e >= 80))flg = 0;
			else flg = -1;

			if (flg == 1)cout << 'A' << endl;
			else if (flg == 0)cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
	return 0;
}

C++: #include<stdio.h>

void dividing_student(int a, int b, int c);

int main(void)
{
    int n;/*nはデータの個数*/
    scanf("%d", &n);
    for( int i = 0; i < n; ++i){
    int pm ,pe, pj; /*左から数学、英語、国語の点数*/
    scanf("%d %d %d", &pm, &pe, &pj);
    dividing_student( pm, pe, pj);
    }
    return 0;
}

void dividing_student( int a, int b, int c)
{
    if( a >= 100|| b >= 100 || c >=100){
        printf("A\n");
    }else if( (a + b) / 2 >= 90){
        printf("A\n");
    }else if( (a + b + c) / 3 >= 80){
        printf("A\n");
    }else if( (a + b + c) / 3 >= 70){
        printf("B\n");
    }else if((a + b + c) / 3 >= 50 && (a >= 50 || b >= 50)){
        printf("B\n");
    }else{
        printf("C\n");
    }
}

C++: #include <iostream>
#include <stdio.h>

char judge(int, int, int);

int main() 
{
	int pm, pe, pj;
	int number;
	
	while (true) {
		std::cin >> number;
		
		if (number == 0) {
			break;
		}
		
		for (int i = 0; i < number; i++) {
			std::cin >> pm >> pe >> pj;
			std::cout << judge(pm, pe, pj) <<std::endl;
		}
	}
	return 0;
}

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

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

C++: #include<stdio.h>
int main(void)
{
	int n,i;
	int pm,pe,pj;
	int meh,h;
	int flg=0;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&pm,&pe,&pj);
			meh=(pm+pe)/2;
			h=(pm+pe+pj)/3;
			if(pe>=80 || pj>=80){
				flg=1;
			}
			if(pm==100 || pe==100 || pj==100){
				printf("A\n");
			}
			else if(meh>=90){
				printf("A\n");
			}
			else if(h>=80){
				printf("A\n");
			}
			else if(h>=70){
				printf("B\n");
			}
			else if(h>=50 && flg==1){
				printf("B\n");
			}
			else{
				printf("C\n");
			}
		}
		scanf("%d",&n);
	}
	return 0;
}

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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    while (n--) {
      int pm, pe, pj;
      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;
    }
  }
  return 0;
}

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

C++: #include<cstdio>
int main(){
    int n;
    for(;;){
        scanf("%d",&n);
        if(n==0) break;
        for(int i=0;i<n;i++){
            int p[3];
            char r='C';
            for(int j=0;j<3;j++){
                scanf("%d",&p[j]);
            }
            int sum=0,sumb=0;
            for(int j=0;j<3;j++){
                if(p[j]==100){
                    r='A';
                }
                sum+=p[j];
                if(j!=2) sumb+=p[j];
            }
            if(r=='C'){
                if(sumb/2>=90||sum/3>=80) r='A';
                else if(sum/3>=70) r='B';
                else if(sum/3>=50 && (p[0]>=80 || p[1]>=80)) r='B';
            }
            printf("%c\n",r);
        }
    }
}

C++: #include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		double m,e,j;
		rep(i,0,n){
			cin>>m>>e>>j;
			if(max(m,max(e,j))==100) o('A');
			else if(m+e>=180) o('A');
			else if(m+e+j>=240) o('A');
			else if(m+e+j>=210) o('B');
			else if(m+e+j>=150 && max(m,e)>=80) o('B');
			else o('C');
		}

	}
}

C++: #include<stdio.h>

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

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

void dividing(int pm, int pe, int pj)
{
  if (pm == 100 || pe == 100 || pj == 100) {
    printf("A\n");
  }
  else if ((pm + pe) / 2 > 90){
    printf("A\n");
  }
  else if ((pm + pe + pj) / 3 >80){
    printf("A\n");
  }
  else if ((pm + pe + pj) / 3 > 70){
    printf("B\n");
  }
  else if((pm + pe + pj) / 3 > 50 && (pm > 80 || pe > 80)){
    printf("B\n");
  } else {
    printf("C\n");
  }
}

C++: #include <iostream>
using namespace std;
int main()
{
	while(true){
		int n;
		cin >>n;
		if(n==0)
			break;

		int pm,pe,pj;
		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 << 'B' << endl;
			else if((pm+pe+pj) /3 >=70)
				cout << 'B' << endl;
			else if((pm>=80 ||pe>=80) &&(pm+pe+pj) / 3 >=50)
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	while(true){
		int n;
		cin >>n;
		if(n==0)
			break;

		int pm,pe,pj;
		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>=80 ||pe>=80) &&(pm+pe+pj) / 3 >=50)
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
	return 0;
}