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(void)
{
	int n;

	while(cin >> n, n){
		int a,b,c;

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

	return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	while(true){
		int n;
		cin >>n;
		if(n==0)
			break;

		int pm,pe,pj;
		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 << 'B' << endl;
			else if((pm+pe+pj) /3 >70)
				cout << 'B' << endl;
			else if(pm>=80 ||pe>=80 &&(pm+pe+pj) / 3 >50)
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
   int n,a,b,c;

   while(true){
       scanf("%d",&n);
       if(n == 0)break;

       for(int i = 0; i < n; i++){
           scanf("%d %d %d",&a,&b,&c);
           if(a == 100 || b == 100 || c == 100 || a + b >= 180 || a+b+c >= 240){
               printf("A\n");
           }else if((a + b + c >= 210) || (a+b+c>=150 && (a >= 80 || b >= 80))){
               printf("B\n");
           }else{
               printf("C\n");
           }
       }

   }
   return 0;
}

C++: #include <stdio.h>

void Hantei(int p[3])
{
  int flg=0;
  int sum=p[0]+p[1]+p[2];
  if(p[0]==100 || p[1]==100 || p[2]==100)
    {
      printf("A\n");
      return;
    }
  if((p[0]+p[1])>=180)
    {
      printf("A\n");
      return;
    }
  if(sum>=240)
    {
      printf("A\n");
      return;
    }
  if(sum>=210)
    {
      printf("B\n");
      return;
    }
  if(sum>=150 && (p[0]>=80 || p[1]>=80))
    {
      printf("B\n");
      return;
    }

  printf("C\n");
}

int main(void)
{
  while(1)
    {
      int n;
      
      scanf("%d",&n);

      if(n==0)
	{
	  break;
	}

      int p[n][3];

      for(int i=0;i<n;i++)
	{
	  scanf("%d %d %d",&p[i][0],&p[i][1],&p[i][2]);
	}

      for(int i=0;i<n;i++)
	{
	  Hantei(p[i]);
	}
    }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    while (n--) {
      int m, e, j;
      cin >> m >> e >> j;
      char a = 'C';
      int mean = (m + e + j) / 3;
      if (m == 100 || e == 100 || j == 100) a = 'A';
      else if ((m + e) / 2 >= 90) a = 'A';
      else if (mean >= 80) a = 'A';
      else if (mean >= 70) a = 'B';
      else if (mean >= 50 && (m >= 80 || e >= 80)) a = 'B';
      cout << a << "\n";
    }
  }
}

C++: #include<iostream>
using namespace std;
int main()
{
	while (true)
	{
		int s, m = 0, e = 0, j = 0, sum[7];
		cin >> s;
		if (s == 0)break;
		for (int i = 0; i < s; i++)
		{
			cin >> m >> e >> j;
			if (m == 100 || e == 100 || j == 100)
			{
				cout << "A" << endl;
			}
			else
			{
				sum[0] = (m + e) / 2;
				if (sum[0] >= 90)
				{
					cout << "A" << endl;
				}
				else
				{
					sum[1] = (m + e + j) / 3;
					if (sum[1] >= 80)
					{
						cout << "A" << endl;
					}
					else
					{
						if (sum[1] >= 70)
						{
							cout << "B" << endl;
						}
						else
						{

							if (sum[1] >= 50 && m >= 80 || e >= 80)
							{
								cout << "B" << endl;
							}
							else cout << "C" << endl;
						}
					}
				}
			}
		}
	}
}

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 = pm + pe + pj;
    char class;

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

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

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

char judge(int pm, int pe, int pj)
{
    if(pm == 100 || pe == 100 || pj == 100 || pm + pe >= 180 || pm + pe + pj >= 240) return 'A';
    else if(pm + pe + pj >= 210 || pm + pe + pj >= 150 && (pm >= 80 || pe >= 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 << judge(pm,pe,pj) << endl;
        }
    }
}

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

int main(void)
{
	while (1) {
		int number;
		scanf("%d", &number);
		if (number == 0) {
			break;
		}
		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>
#include <iostream>

using namespace std;

int main() {
	int n;
	int pm,pe,pj;
	double ave,meave;
	while (1) {
		cin >> n;
		if (n == 0) {
			break;
		} else {
			for (int i = 0; i < n; i++) {
				cin >> pm >> pe >> pj;
				ave = ((double)pm + (double)pe + (double)pj) / 3.0;
				meave = ((double)pm + (double)pe) / 2.0;
				if (pm == 100 || pe == 100 || pj == 100) {
					cout << "A" << endl;
				} else if (meave >= 90.0) {
					cout << "A" << endl;
				} else if (ave >= 80.0) {
					cout << "A" << endl;
				} else if (ave >= 70.0) {
					cout << "B" << endl;
				} else if (ave >= 50.0 && (pm >= 80.0 || pe >= 80.0)) {
					cout << "B" << endl;
				} else {
					cout << "C" << endl;
				}
			}
		}
	}
	return 0;
}