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<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		rep(i, n) {
			int pm, pe, pj;
			cin >> pm >> pe >> pj;

			int ave = (pm + pe + pj) / 3;
			int me_ave = (pm + pe) / 2;
			if (pm == 100 || pe == 100 || pj == 100 || ave >= 80 || me_ave >= 90)
				cout << 'A' << endl;
			else if (ave >= 70 || (ave >= 50 && (pm >= 80 || pe >= 80)))
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
	return	0;
}

C++: #include <stdio.h>

int weather_right_triangle(int, int, int);

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

int weather_right_triangle(int a, int b, int c)
{
	if (a * a + b * b == c * c || 
		b * b + c * c == a * a || 
		a * a + c * c == b * b) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}
	return 0;
}

C++: #include<stdio.h>

int main(void){
	int i,n,t1,t2,j,m,e;
	while(0==0)
	{
		scanf("%d",&n);
		if(n==0)break;

		for(i=0;i<n;i++){
			scanf("%d %d %d",&m,&e,&j);
			t1=m+e;  t2=m+e+j;
			if((m==100 || e==100 || j==100) || (t1>=180) || (t2>=240))
				printf("A\n");
			else if((t2>=210) || (t2>=150 && ( m>=80 || e>=80)))
				printf("B\n");
			else printf("C\n");
		}
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>

using namespace std;

int main(int argc, char *argv[]) {
  int n, pm, pe, pj;
  while (cin >> n, n) {
    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;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int N, A, B, C;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		for (int i = 0; i < N; i++)
		{
			cin >> A >> B >> C;

			if (A == 100 || B == 100 || C == 100)
			{
				cout << "A" << endl;
			}
			else if (A + B >= 180)
			{
				cout << "A" << endl;
			}
			else if (A + B + C >= 240)
			{
				cout << "A" << endl;
			}
			else if (A + B + C >= 210)
			{
				cout << "B" << endl;
			}
			else if (A + B + C >= 150 && (A >= 80 || B >= 80))
			{
				cout << "B" << endl;
			}
			else
			{
				cout << "C" << endl;
			}
		}
	}

	return 0;
}

C++: #include <stdio.h>

int grading(int pm, int pe, int pj);

int main(void)
{
    int number;
    int pm, pe, pj;
    scanf("%d", &number);// number of students to grade                                                                                                                              
    for (int j = 0; j < number; j++) {
      int grade;
      scanf("%d %d %d", &pm, &pe, &pj);
      grade = grading(pm, pe, pj);
      if (grade == 1) {// grade 1 means class A                                                                                                                                      
        printf("A\n");
      } else if (grade == 2) {//grade 2 means class B                                                                                                                                
        printf("B\n");
      } else if (grade == 3) {//grade 3 means class C                                                                                                                                
        printf("C\n");
      }
    }
    return 0;
}

int grading(int pm, int pe, int pj)
{
    int grade;
    if (pm == 100 || pe == 100 || pj == 100) {
      grade = 1;
    } else if ((pm + pe) / 2 >= 90) {
      grade = 1;
    } else if ((pm + pe + pj) / 3 >= 80) {
      grade = 1;
    } else if ((pm + pe + pj) / 3 >= 70) {
      grade = 2;
    } else if ((pm + pe + pj) / 3 >= 50 && (pm >=80 || pe >=80)) {
      grade = 2;
    } else {
      grade = 3;
    }
    return grade;
}

C++: #include <stdio.h>

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

int main(void)
{
    int n, pm, pe, pj;
    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        char score[n];
        for (int i = 0; i < n; i++) {
            scanf("%d %d %d",&pm, &pe, &pj);
            score[i] = judge(pm, pe, pj);
        }
        for (int i = 0; i < n; i++) {
            printf("%d\n", score[i]);
        }
    }
    return 0;
}

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

C++: #include <iostream>

char jukuClass(int, int, int);
int main()
{
    while (true) {
        int number;
        std::cin >> number;
        if (number == 0) {
            break;
        }
        for (int i = 0; i < number; ++i) {
            int pm, pe, pj;
            std::cin >> pm >> pe >> pj;
            std::cout << jukuClass(pm, pe, pj) << std::endl;
        }
    }
    return 0;
}
char jukuClass(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
        return 'A';
    } else if ((pm + pe) / 2.0 >= 90) {
        return 'A';
    } else if ((pm + pe + pj) / 3.0 >= 80) {
        return 'A';
    } else if ((pm + pe + pj) / 3.0 >= 70) {
        return 'B';
    } else if (((pm + pe + pj) / 3.0 >= 50) && (pm >= 80 || pe >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}