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>
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){
				cls[i]=1;
				flg++;
			}
			if((m+e)/2>=90){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)/3>=80){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)/3>=70&&(m+e+j)/3<90){
				flg++;
				cls[i]=2;
			}
			if(((m+e+j)/3>=50&&(m+e+j)/3<90)&&((m>=80&&m<100)||(e>=80&&e<100))){
				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 <stdio.h>

float mean2(int x, int y)
{
    return (float)(x + y) / 2.0;
}

float mean3(int x, int y, int z)
{
    return (float)(x + y + z) / 3.0;
}

char grading(int p_math, int p_eng, int p_jpn)
{
    if ( p_math == 100 || p_eng == 100 || p_jpn == 100) {
        return 'A';
    } else if (mean2(p_math, p_eng) >= 90.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 80.0) {
        return 'A';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0) {
        return 'B';
    } else if (mean3(p_math, p_eng, p_jpn) >= 70.0 && (p_math >= 80 || p_eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    int i, p_math, p_eng, p_jpn, n_iteration;
    char grade;

    while (1) {
        scanf("%d", &n_iteration);

        if (n_iteration == 0) {
            break;
        }

        for (i = 0; i < n_iteration; i++) {
            scanf("%d %d %d", &p_math, &p_eng, &p_jpn);
            grade = grading(p_math, p_eng, p_jpn);
            printf("%c\n", grade);
        }
    }
    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 <iostream>
using namespace std;
int main(){
	int pm,pj,pe,n,i;
	while(cin >> n&&n){
		for(i=0;i<n;i++){
			cin >> pm >> pe >> pj;
			double ave = (pm+pe+pj)/3;
			if(pm == 100 || pe == 100 || pj == 100) cout << 'A' << endl;
			else if((pm+pe)/2 >= 90 || ave >= 80) cout << 'A' << endl;
			else if(ave >= 70) cout << 'B' << endl;
			else if(ave >= 50 && pe >= 80) cout << 'B' << endl;
			else if(ave >= 50 && pm >= 80) cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
	return 0;
}

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){
				flg++;
				cls[i]=2;
			}
			if((m+e+j)/3>=50&&(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++: #define scanf_s scanf
#include <stdio.h>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <iostream>
using namespace std;

#define MAX 100000

int main()
{
	while (1) {
		int n, pm, pe, pj, sum;
		scanf_s("%d", &n);
		if (n == 0)break;
		for (int i = 0; i < n; ++i) {
			scanf_s("%d %d %d", &pm, &pe, &pj);
			sum = pm + pe + pj;
			if ((pm == 100 || pe == 100) || pj == 100) printf("A\n");
			else if(pm + pe >= 180) printf("A\n");
			else if (sum >= 240) printf("A\n");
			else if (sum >= 210 && (pm >= 80 || pe >= 80)) printf("A\n");
			else if (sum >= 210) printf("B\n");
			else if (sum >= 150 && (pm >= 80 || pe >= 80 )) printf("B\n");
			else printf("C\n");
		}
	}
}

C++: #include <bits/stdc++.h>

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    while (n = in()){
        rep(i, n){
            int pm, pe, pj;
            pm = in();
            pe = in();
            pj = in();
            int all_ave = (pm + pe + pj) / 3.;
            int me_ave = (pm + pe) / 2.;
            int is_perfect = pm == 100 || pe == 100 || pj == 100;
            if (is_perfect || me_ave >= 90 || all_ave >= 80){
                puts("A");
            }
            else if (all_ave >= 70 || (all_ave >= 50 && max(pm, pe) >= 80)){
                puts("B");
            }
            else {
                puts("C");
            }
        }
    }

    return (0);
}

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



int main(){
  struct test{
    int Math;
    int English;
    int Japanese;
  };

  int n,total;
  test student;

  while(1){

    char rank='A';
    total=0;
    cin >> n;
    if(n==0)break;

    for(int i=0;i<n;i++){
      while(1){
	cin >> student.Math >> student.English >> student.Japanese;
	if(student.Math==100||student.English==100||student.Japanese==100)break;
	total=student.Math+student.English;
	total=total/2;
	if(total>=90)break;
	total=student.Math+student.English+student.Japanese;
	total=total/3;
	if(total>=80)break;
	
	rank='B';
	if(total>=70)break;
	if(total>=50&&(student.Math>=80||student.English>=80))break;
	
	rank='C';
	if(1)break;
      }
      cout << rank << endl;
    }
  }
}

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

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

int main()
{
	int n;
	while(cin >> n, n)
	{
		int pm,pe,pj;
		while(n--)
		{
			cin >> pm >> pe >> pj;
			
			if(pm==100 || pe==100 || pj==100)
			{
				cout << 'A' << endl; continue;
			}

			if((pm+pe)/2 >= 90)
			{
				cout << 'A' << endl; continue;
			}

			if((pm+pe+pj)/3 >= 80)
			{
				cout << 'A' << endl; continue;
			}

			if((pm+pe+pj)/3 >= 70)
			{
				cout << 'B' << endl; continue;
			}

			if((pm+pe+pj)/3 >= 50 && (pm>=80 || pe>=80))
			{
				cout << 'B' << endl; continue;
			}

			cout << 'C' << endl;
		}
	}
}