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;

int main()
{
	int N;

	while ( cin >> N, N != 0 ) {

		while ( N > 0 ) {
			int a, b, c;
			cin >> a >> b >> c;
			if ( a == 100 || b == 100 || c == 100 || a + b + c >= 240 || a + b >= 180 ) {
				cout << "A" << endl;
			} else if ( a + b + c >= 210 || a + b + c >= 150 && (a >= 80 || b >= 80) ) {
				cout << "B" << endl;
			} else {
				cout << "C" << endl;
			}
			N--;
		}
	}

	return ( 0 );
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n;
double a, b, c;
char ans;

int main(){
	while (cin >> n&&n){
		REP(i, n){
			cin >> a >> b >> c;
			if (a == 100 || b == 100 || c == 100 ||
				(a + b) / 2 >= 90 || (a + b + c) / 3 >= 80){
				ans = 'A';
			}
			else if ((a + b + c) / 3 >= 70 
				|| ((a >= 80 || b >= 80) && (a + b + c) / 3 >= 50)){
				ans = 'B';
			}
			else ans = 'C';
			cout << ans << 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||(m+e)/2>=90||(m+e+j)/3>=80){
				cls[i]=1;
				flg=1;
			}
			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||e>=80)){
				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 <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) cout << "B";
        else if (b >= 80) cout << "B";
      }
      cout << "C";
      cout << endl;
    }
  }
}

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

int main(){
	
	int n;
	while(cin>>n){
		if(n!=0){
	while(n>0){
		int pm,pe,pj;
		cin>>pm>>pe>>pj;
		if(pm=100||pe==100||pj==100||pm>=90||(pm+pe)/2>=90||(pm+pe+pj)/3>=80)
			cout<<"A"<<endl;
		else if((pm+pe+pj)/3>=70||((pm+pe+pj)/3>=50&&pm>=80||pe>=80))
			cout<<"B"<<endl;
		else
			cout<<"C"<<endl;
		n--;
	}
	}
		else
			break;
	}

	

}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

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

C++: #include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int i,n;
  int pm,pe,pj;
 while(1){
   cin>>n;
   if(n==0)break;

   for(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){
       if(pm>=80||pe>=80) cout<<'B'<<endl;
       else cout<<'C'<<endl;
     }
     else  cout<<'C'<<endl;

   }
 }   
 return 0;
}

C++: #include <stdio.h>

void dividing_students(int n);

int main(void)
{
    int n;
    scanf("%d", &n);
    while (n != 0) {
        dividing_students(n);
        scanf("%d",&n);
    }
    return 0;
}

void dividing_students(int n)
{
    for (int i = 1; i <= n; ++i) {
        int math, english, japanese;
        scanf("%d %d %d", &math, &english, &japanese);
        if (math == 100 || english == 100 || japanese == 100) {
            printf("A\n");
        } else if (math + english >= 180) {
            printf("A\n");
        } else if (math + english + japanese >= 240) {
            printf("A\n");
        } else if (math + english + japanese >= 210) {
            printf("B\n");
        } else if ((math + english + japanese >= 150) && (math >= 80 || english >= 80)) {
            printf("B\n");
        } else {
            printf("C\n");
        }
    }
}

C++: /*
    2014.07.04 1259~1307
    C language Lecture week ∞
*/

#include <stdio.h>
#include <string.h>

char classify ( int score_math, int score_eng, int score_jpn );

int main (void) {
    
    int score_math = -1;
    int score_eng = -1;
    int score_jpn = -1;
    
    int max = -1;
    
    scanf ( "%d", &max );
    
    for ( int cnt = 0; cnt < max; cnt ++ ) {
        scanf ( "%d", &score_math );
        scanf ( "%d", &score_eng );
        scanf ( "%d", &score_jpn );
        printf ( "%c\n", classify ( score_math, score_eng, score_jpn ) );
    }
    
    return 0;
    
}

char classify ( int score_math, int score_eng, int score_jpn ) {
    char out;
    int score_me = ( score_math + score_eng );
    int score_mej = ( score_math + score_eng + score_jpn );
    
    if ( score_math == 100 || score_eng == 100 || score_jpn == 100 ) {
        out = 'A';
    } else if ( score_me >= 180 ) {
        out = 'A';
    } else if ( score_mej >= 240 ) {
        out = 'A';
    } else if ( score_mej >= 210 ) {
        out = 'B';
    } else if ( score_mej >= 150 && ( score_math >= 80 || score_eng >= 80 ) ) {
        out = 'B';
    } else {
        out = 'C';
    }
    
    return out;
}