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 n;
  while( cin >> n,n ){
    for(int i = 0 ; i < 3 ; i++){
      int a,b,c;
      cin >> a >> b >> c;
      if(a == 100 || b == 100 || c == 100)cout << "A" <<endl;
      else if((a+b)/2 >= 90)cout << "A" <<endl;
      else if((a+b+c)/3 >= 80)cout << "A" <<endl;
      else if((a+b+c)/3 >= 70)cout << "B" <<endl;
      else if((a+b+c)/3 >= 50 && (a >= 80 || b>=80))cout << "B" <<endl;
      else cout << "C" << endl;
    }
  }
  return 0;
}

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 <stdio.h>

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

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

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

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;
}

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

using namespace std;

int main()
{
	int pm, pe, pj;
	int n;

	while (scanf("%d", &n), n != 0){
		for (int i = 0; i < n; i++){
			scanf("%d%d%d", &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<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<utility>

using namespace std;

int n;

char student[10010];

double cal(int m,int e,int j)
{
	double ave = (double)(m + e + j) / 3;

	return ave;
}

int main(void)
{
	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)
			{
				student[i] = 'A';

				continue;
			}
			if (((double)(m+e)/2)>=90)
			{
				student[i] = 'A';

				continue;
			}

			if (cal(m,e,j)>=80)
			{
				student[i] = 'A';

				continue;
			}

			if (cal(m, e, j) >= 70)
			{
				student[i] = 'B';

				continue;
			}

			if (cal(m, e, j) >= 50)
			{
				if (m>=80||e>=80)
				{
					student[i] = 'B';

					continue;
				}
			}

			student[i] = 'C';

		}

		for (int i = 0; i < n; i++)
		{
			cout << student[i] << endl;
		}
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
#define endl    '\n'
using namespace std;

typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    int ma, en, ja, avg;
    char cls;

    cin >> n;

    while (n != 0) {
        for (int i = 0; i < n; ++i) {
            cin >> ma >> en >> ja;
            avg = (ma + en + ja) / 3;

            if (ma == 100 || en == 100 || ja == 100 || (ma + en) / 2 >= 90 || avg >= 80) {
                cls = 'A';
            } else if (avg >= 70 || avg >= 50 && (ma >= 80 || en >= 80)) {
                cls = 'B';
            } else {
                cls = 'C';
            }

            cout << cls << endl;
        }

        cin >> n;
    }

    return 0;
}

C++: // 2013/09/17 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int pm, pe, pj;
			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 <stdio.h>

int dividing(int math, int english, int 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) {
		printf("B\n");
	} else if (math + english + japanese >= 150 && english >= 80) {
		printf("B\n");
	} else {
		printf("C\n");
	}
	return 0;
}

int main(void)
{
	int number;
	scanf("%d", &number);
	for (int i = 0; i < number; i++) {
		int math;
		int english;
		int japanese;
		scanf("%d %d %d", &math, &english, &japanese);
		dividing(math, english, japanese);
	}
}

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<bits/stdc++.h>
using namespace std;
char getClass(int m, int e, int j) {
	if (m == 100 || e == 100 || j == 100 || (m + e) / 2 >= 90
			|| (m + e + j) / 3 >= 80)
		return 'A';
	if ((m + e + j) / 3 >= 70 || (m + e + j) / 3 >= 50 && m >= 80 || e >= 80)
		return 'B';
	return 'C';
}
int main() {
	int n, pm, pe, pj;
	while (cin >> n && n) {
		for (int i = 0; i < n; i++) {
			cin >> pm >> pe >> pj;
			cout << getClass(pm, pe, pj) << endl;
		}
	}
	return 0;
}