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 judge(int pm, int pe, int pj);

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

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &pm, &pe, &pj);
                judge(pm, pe, pj);
            }
        }
    }

    return 0;
}

void judge(int pm, int pe, int pj)
{
    int sum;
    sum = pm + pe + pj;
    char class;

    if (pm == 100 || pe == 100 || pj == 100){
        class = 'A';
    } else if (pm + pe >= 180){
        class = 'A';
    } else if (sum >= 240){
        class = 'A';
    } else if (sum >= 210){
        class = 'B';
    } else if (sum >= 150 && (pm >= 80 || pe >= 80)){
        class = 'B';
    } else {
        class = 'C';
    }

    printf("%c\n", class);
}

C++: #include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int n, m, e, j;
	while(cin >> n, n) {
		rep(i,n) {
			cin >> m >> e >> j;
			int t = m+e+j;
			if(m==100||e==100||j==100||m+e>=180||t>=240) cout << "A" << endl;
			else if(t>=210||t>=150&&(m>=80||e>=80)) cout << "B" << endl;
			else cout << "C" << endl;
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

	int n;
	while(cin>>n&&n!=0){
		for(int i = 0; i < n; i++){
			int pm,pe,pj;
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||pj==100||((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;
		}
	}

	return 0;
}

C++: #include <stdio.h>

char divide(int math, int english, int japanese);
char class;

int main(void)
{
    int dataset;
    int math, english, japanese;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &math, &english, &japanese);
                class = divide(math, english, japanese);
                printf("%c\n", class);
            }
        }
    }

    return 0;
}

char divide(int math, int english, int japanese)
{
    int sum = math + english + japanese;

    if (math == 100 || english == 100 || japanese == 100){
        class = 'A';
    } else if (math + english >= 90 * 2){
        class = 'A';
    } else if (sum >= 80 * 3){
        class = 'A';
    } else if (sum >= 70 * 3){
        class = 'B';
    } else if (sum >= 50 * 3 && (math >= 80 || english >= 80)){
        class = 'B';
    } else {
        class = 'C';
    }

    return class;
}

C++: #include<stdio.h>

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

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

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

C++: #include <iostream>

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

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

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

int main(){
	int n;
	while(cin >> n){
	if(n == 0){break;}
	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[iii] << endl;
	}
}
}

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

int main()
{
  int n, m, e, j;
  while(1)
  {
    cin >> n;
    if(!n)
      break;

    for(int i = 0; i < n ; i++)
    {
      cin >> m >> e >> j;
      if((m + e) / 2 >= 90 || m == 100 || e == 100 || j == 100 || (m + e + j) / 3 >= 80)
        cout << 'A' << endl;
      else if((m + e + j) / 3 >= 70 || (m + e + j) / 3 >= 50 && (m >= 80 || e >= 80))
        cout << 'B' << endl;
      else
        cout << 'C' << endl;
    }
  }
}

C++: #include <stdio.h>

int divide(int, int, int);

int main(void)
{
	int n;
	scanf("%d", &n);
	int grade[n][3];
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &grade[i][0], &grade[i][1], &grade[i][2]);
		divide(grade[i][0], grade[i][1], grade[i][2]);
	}
	return 0;
}

int divide(int m, int e, int j)
{
	if (m == 100 || e == 100 || j == 100 ||
		(m + e) / 2 >= 90 ||
		(m + e + j) / 3 >= 80) {
		printf("A\n");
	} else if ((m + e + j) / 3 >= 70 ||
		       ((m + e + j) / 3 >= 50 && (m >= 80 || e >= 80))) {
		printf("B\n");
	} else {
		printf("C\n");
	}
	return 0;
}

C++: #include<stdio.h>
 
int main(void){
    int i,k;
    int h1,m1,s1,h2,m2,s2;
    int sum1,sum2;
 
    while(scanf("%d",&k)==0){
       for(i=0;i<k;i++){
        scanf("%d %d %d",&h1,&m1,&s1);
        sum1=h1+m1;
        sum2=h1+m1+s1;
       if((h1==100||m1==100||s1==100)||sum1=>180||sum2==270) printf("A\n");
       else if(sum1=>210||(sum1=>150&&(h1=>80||m1=>80)) printf("B\n");
       else printf("C\n");
    }
    }
    return 0;
}

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

int main(){
	int n;
	while(cin >> n){
	if(n == 0){break;}
	int t[100],tt[200],i,ii;
	string ans[1000];
	i = 1;
	for(i = 1;n >= i;i++){
			//cout << i << endl;
			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 tt[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";
			}
	}
	ii = 1;
	//cout << "OK" << endl;
	for(ii = 1;n >= ii;ii++){
		cout << ans[ii] << endl;
	}
}
}