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 argc, char** argv){
	int n, pm, pe, pj;
	
	while( 1 ){
		cin >> n;
		if(n==0) break;
		
		for(int i=0; i<n; i++){
			cin >> pm;
			cin >> pe;
			cin >> pj;
			
			if(pm==100 || pe==100 || pj==100){
				cout << "A" << endl;
				continue;
			}
			
			if((pm+pe) / 2 >= 90){
				cout << "A" << endl;
				continue;
			}
			
			int avg = (pm + pe + pj) / 3;
			if(avg >= 80){
				cout << "A" <<endl;
				continue;
			}
			
			if(avg >= 70){
				cout << "B" << endl;
				continue;
			}
			
			if(avg>=50 && pm>=80){
				cout << "B" << endl;
				continue;
			}
			
			cout << "C" << endl;
		}
	}
	
	return 0;
}

C++: #include <iostream>

char detClass(int pm, int pe, int pj)
{
	
	int mean = pm + pe + pj;
	if((pm == 100) | (pe == 100) | (pj == 100)) {
		return 'A';
	} else if( (pm + pe)/2 >= 90) {
		return 'A';
	} else if( mean >= 240) {
		return 'A';
	} else if( mean >= 140) {
		return 'B';
	} else if( (mean >= 100) && ((pm >= 80) | (pe >= 80))) {
		return 'B';
	} else {
		return 'C';
	}
}

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

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>

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		for(int i = 0; i < n; ++i)
		{
			int m, e, j;
			cin >> m >> e >> j;
			if((m == 100 || e == 100 || j == 100) || (m + e >= 180) || (m + e + j >= 240))
			{
				cout << "A" << endl;
			}
			else if((m + e + j >= 210) || (m + e + j >= 150 && (e >= 80 || m >= 80)))
			{
				cout << "B" << endl;
			}
			else
			{
				cout << "C" << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
using namespace std;
char judge(int, int, int);

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

		for (int i = 0;i < n;i++) {
			cin >> pm >> pe >> pj;
			cout << judge(pm, pe, pj) << endl;
		}
	}
}

char judge(int math, int eng, int jap) {
	float twoave = (math + eng) / 2;
	float ave = (math + eng + jap) / 3;
	if (math == 100 || eng == 100 || jap == 100) {
		return 'A';
	} else if (twoave >= 90) {
		return 'A';
	} else if (ave >= 80) {
		return 'A';
	} else if (ave >= 70) {
		return 'B';
	} else if (ave >= 50 && (math >= 80 || eng >= 80)) {
		return 'B';
	} else {
		return 'C';
	}
}

C++: #include <cstdio>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int main(){
	int n;
	while(cin >> n){
	int t[3],tt[2];
	string ans[n];
	for(int i = 1;n >= i;i++){
		for(int ii = 1;3 >= ii;ii++){
			cin >> t[1] >> t[2] >> t[3];
			tt[1] = ( t[1] + t[2] ) / 2;
			tt[2] = ( t[1] + t[2] + t[3]) / 3;
			if(t[1] == 100 or t[2] == 100 or t[3] == 100 or  tt[1] >= 90 or t[2] >= 80){
				ans[i] = "A";
			}else if(tt[2] >= 70){
				ans[i] = "B";
			}else if(tt[2] >= 50 and t[1] >= 80 or tt[2] >= 50 and t[2] >= 80){
				ans[i] = "B";
			}else{
				ans[i] = "C";
			}
		}
	}
	for(int iii = 1;n >= iii;iii++){
		cout << ans[i] << endl;
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
using namespace std;
struct student{
  int math, eng, nat;
  double ave;
};

string solve(student s){
  if(s.math == 100 || s.eng == 100 || s.nat == 100){
    return "A";
  }else if(s.ave >= 80){
    return "A";
  }else if((s.math + s.eng)/2.0 >= 90){
    return "A";
  }else if(s.ave >= 70){
    return "B";
  }else if(s.ave >= 50 && (s.math >= 80 || s.eng >= 80)){
    return "B";
  }
  return "C";
}
  
int main(){
  int n;
  while(std::cin >> n, n){
    for (int i = 0; i < n; i++) {
      student s;
      std::cin >> s.math >> s.eng >> s.nat;
      s.ave = (s.math + s.eng + s.nat)/3.0;
      std::cout << solve(s) << std::endl;
    }
  }
  return 0;
}

C++: #include <stdio.h>

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

int main(void)
{
    int a;
    int pm, pe, pj;

    while(1) {
        scanf("%d", &a);
        
        if (a == 0) {
            break;
        }
    
        for (int i = 0; i < a; i++) {
            scanf("%d %d %d", &pm, &pe, &pj);
            printf("%c\n", cat_stu(pm, pe, pj));
        }
    }
        
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
using namespace std;

int main() {
  int n;
  for(;;) {
    cin >> n;
    if(n == 0) break;
    string s[n];

    int pm, pe, pj;
    for(int i=0; i<n; ++i) {
      cin >> pm >> pe >> pj;
      if(pm == 100 || pe == 100 || pj == 100) s[i] = "A";
      else if((pm + pe) / 2 >= 90) s[i] = "A";
      else if((pm + pe + pj) / 3 >= 80) s[i] = "A";
      else if((pm + pe + pj) / 3 >= 70) s[i] = "B";
      else if((pm + pe + pj) / 3 >= 50 && (pm >= 80 || pe >= 80)) s[i] = "B";
      else s[i] = "C";
    }

    for(int i=0; i<n; ++i) cout << s[i] << endl;

  }
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void)
{
	vector< vector<int> > p( 10000,vector<int>(3) );
	vector<char> ans(10000);
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin >> p[i][0] >> p[i][1] >> p[i][2];
			if(p[i][0]==100||p[i][1]==100||p[i][2]==100) ans[i]='A';
			else if(90*2<=p[i][0]+p[i][1]) ans[i]='A';
			else if(80*3<=p[i][0]+p[i][1]+p[i][2]) ans[i]='A';
			else if(70*3<=p[i][0]+p[i][1]+p[i][2]) ans[i]='B';
			else if(50*3<=p[i][0]+p[i][1]+p[i][2]&&(80<=p[i][0]||80<=p[i][1])) ans[i]='B';
			else ans[i]='C';
		}
		for(int i=0;i<n;i++) cout << ans[i] << endl; 
		p.clear();
		ans.clear();
	}
	return 0;
}

C++: g#include <iostream>

using namespace std;

char divide(int m, int e, int j) {
    if (m == 100 || e == 100 || j == 100) return 'A';
    if ( (m+e)/2 >= 90 ) return 'A';
    if ( (m+e+j)/3 >= 80 ) return 'A';
    if ( (m+e+j)/3 >= 70 ) return 'B';
    if ( (m+e+j)/3 >= 50 && (m >= 80 || e >= 80) ) return 'B';
    return 'C';
}

int main() {
    int n;
    while (cin >> n, n) {
        while (n--) {
            int pm, pe, pj;
            cin >> pm >> pe >> pj;
            cout << divide(pm, pe, pj) << endl;
        }
    }
    return 0;
}