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 <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){
        if (a >= 80 || b >= 80) cout << "B";
      }
      else cout << "C";
      cout << endl;
    }
  }
}

C++: #include<cstdio>
#include<algorithm>
int main(void)
{
	int n,pm[10000],pe[10000],pj[10000],i,j;
	scanf("%d",&n);
	while(n!=0){
		j=0;
		for(i=0;i<n;i++)
			scanf("%d %d %d",&pm[i],&pe[i],&pj[i]);
		for(i=0;i<n;i++){
			if(pm[i]==100||pe[i]==100||pj[i]==100||(pm[i]+pe[i])/2>=90||(pm[i]+pe[i]+pj[i])/3>=80)
				printf("A\n");
			else if((pm[i]+pe[i]+pj[i])/3>=70||(pm[i]+pe[i]+pj[i])/3>=50&&pm[i]>=80||(pm[i]+pe[i]+pj[i])/3>=50&&pe[i]>=80)
				printf("B\n");
			else
				printf("C\n");
		}
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int main() {
  int n;
  while(cin>>n,n) {
    REP(i,n) {
      int m,e,j;
      cin >> m >> e >> j;
      char c;
      if (m == 100 || e == 100 || j == 100)
        c = 'A';
      else if (m + e >= 180)
        c = 'A';
      else if (m + e + j >= 240)
        c = 'A';
      else if (m + e + j >= 210)
        c = 'B';
      else if (m + e + j >= 150 && (m >= 80 || e >= 80))
        c = 'B';
      else
        c = 'C';
      cout << c << endl;
    }
  }
}

C++: #include <iostream>

using namespace std;

int main() {

	int n, m, e, j;

	while(cin >> n) {
		if(n==0)
			break;
		while(n>0) {
			cin >> m >> e >> j;
			if((m==100||e==100||j==100)||(double)((m+e)/2)>=90||(double)((m+e+j)/3)>=80)
				cout << "A" << endl;
			else if((double)((m+e+j)/3)>=70||((double)((m+e+j)/3)>=50&&(m>=80||e>=80)))
				cout << "B" << endl;
			else
				cout << "C" << endl;
			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>
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<iostream>

int main(){
	int n;
	while(std::cin >> n, n){
		while(n--){
			int pm, pe, pj;
			std::cin >> pm >> pe >> pj;
			int sum = pm + pe + pj;
			if(pm == 100 || pe == 100 || pj == 100){
				std::cout << "A" << std::endl;
			}else if(pm + pe >= 180){
				std::cout << "A" << std::endl;
			}else if(sum >= 240){
				std::cout << "A" << std::endl;
			}else if(sum >= 210){
				std::cout << "B" << std::endl;
			}else if(sum >= 150 && (pm >= 80 || pe >= 80)){
				std::cout << "B" << std::endl;
			}else{
				std::cout << "C" << std::endl;
			}
		}
	}
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n, pm, pe, pj; // n…人数　pm…数学の点数　pe…英語の点数　pj…国語の点数
    while(1){
        cin >> n;
        if(n == 0) break; //終了条件
        
        for(int i=0; i<n; i++){
            cin >> pm >> pe >> pj;
        
            //100点の科目がある⇒Ａ
            if(pm == 100 || pe == 100 || pj == 100){
                cout << "A" << endl;
            }
            
            //数学と英語の平均点が90点以上⇒Ａ
            else if((pm + pe) / 2 >= 90){
                cout << "A" << endl;
            }
            
            //３科目の平均点が80点以上⇒Ａ
            
            else if((pm + pe + pj) / 3 >= 80){
                cout << "A" << endl;
            }
            
            //３科目の平均点が70点以上⇒Ｂ
            else if((pm + pe + pj) / 3 >= 70){
                cout << "B" << endl;
            }
            
            //３科目の平均点が50点以上で，数学か英語が80点以上⇒Ｂ
            else if(((pm + pe + pj) / 3 >= 50) && (pm >= 80 || pe >= 80)){
                cout << "B" << endl;
            }
        
            //上の条件を満たさない⇒Ｃ
            else cout << "C" << endl;
        }
    }
    return 0;
}

/*
　問題の通り条件式を作ります。
　評価の出力は１行です。「else」を忘れないようにしましょう。
　「and(&&)」，「or(||)」に気を付けましょう。
*/

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() {

  int n;
  int pm,pe,pj;


  while(1) {

    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;

}