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>
using namespace std; 

int main(){
    int n, a, b, c, i , ans[10000];
    while(1){
        scanf("%d", &n);
        if(n == 0) break;
        for(i = 0; i < n; i++){
            ans[i] = 0;
            scanf("%d %d %d", &a, &b, &c);
            if((a == 100 || b == 100 || c == 100) || (a + b) / 2 >= 90 || (a + b + c) / 3 >= 80) ans[i] = 2;
            else{
                if((a + b + c) / 3 >= 70 || ((a + b + c) / 3 >= 50 && a >= 80) || ((a + b + c) / 3 >= 50 && b >= 80)) ans[i]++;
            }
        }
       for(i = 0; i < n; i++){
            if(ans > 1) printf("A\n");
            if(ans == 1) printf("B\n");
            if(ans == 0) 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 >= 270) 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 <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;
      return grade;
    } else if ((pm + pe) / 2 >= 90) {
      grade = 1;
      return grade;
    } else if ((pm + pe + pj) / 3 >= 80) {
      grade = 1;
      return grade;
    } else if ((pm + pe + pj) / 3 >= 70) {
      grade = 2;
      return grade;
    } else if ((pm + pe + pj) / 3 >= 50 && (pm >=80 || pe >=80) && (pm + pe) / 2 < 90) {
      grade = 2;
    } else {
      grade = 3;
      return grade;
    }
    return grade;
}

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

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

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

  while(cin >> n){
    if(n==0) break;
    for(int i=0; i<n; i++){
      cin >> pm >> pe >> pj;
      s_class(pm,pe,pj);
    }
  }
  return 0;
}

C++: #include <iostream>

int value (int pm, int pe, int pj);
int main()
{
    int N;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
    int pm, pe, pj;	       
    std::cin >> pm >> pe >> pj;
    if (value (pm, pe, pj) == 1) {
        std::cout << "A" <<std::endl;
        } else if (value (pm, pe, pj) == 2) {
        std::cout << "B" <<std::endl;
        } else {
        std::cout << "C" <<std::endl;
        }
    }
    return 0;
}

int value(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
    return 1;
    } else if (pm + pe >= 180) {
    return 1;
    } else if (pm + pe + pj >= 240) {
    return 1;
    } else if (pm + pe + pj >= 210) {
    return 2; 
    } else if (pm + pe + pj >= 150 && (pm >= 80 || pe >=80) ) {
    return 2;
    }else {
    return 3;
    }
}

C++: #include<iostream>
#define A	cout << 'A' << endl
#define B	cout << 'B' << endl
#define C	cout << 'C' << endl

using namespace std;

struct str
{
	int pm;
	int pe;
	int pj;
};

int main()
{
	while(true)
	{
		int n;
		str info[10001];

		cin >> n;

		if(n == 0)
		{
			return false;
		}

		for(int i = 0; i < n; i++)
		{
			cin >> info[i].pm >> info[i].pe >> info[i].pj;
		}

		for(int i = 0; i < n; i++)
		{
			if(info[i].pe == 100 || info[i].pm == 100 || info[i].pj == 100)
			{
				A;
			}

			else if((info[i].pm + info[i].pe) / 2 >= 90)
			{
				A;
			}

			else if((info[i].pe + info[i].pj + info[i].pm) / 3 >= 80)
			{
				A;
			}

			else if((info[i].pe + info[i].pj + info[i].pm) / 3 >= 70)
			{
				B;
			}

			else if((info[i].pe + info[i].pj + info[i].pm) / 3 >= 50 && info[i].pm >= 80 || info[i].pe >= 80)
			{
				B;
			}

			else
			{
				C;
			}
		}
	}
}

C++: #include <iostream>

int main(){
	int n;
	while(std::cin>>n, n){
		int pm, pe, pj;
		for(int i = 0; i < n; ++i){
			std::cin>>pm>>pe>>pj;
			if((pm == 100 || pe == 100 || pj == 100) || (pm+pe >= 180) || (pm+pe+pj >= 240))std::cout<<'A'<<std::endl;
			else if(pm+pe+pj>=210 || (pm+pe+pj>=150 && pm >= 80 || pe >= 80))std::cout<<'B'<<std::endl;
			else std::cout<<'C'<<std::endl;
		}
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n;
    while(cin>>n,n){
        int pm,pe,pj;
        while(n--){
            cin>>pm>>pe>>pj;
            char res;
            double ave=(pm+pe+pj)/3.0;
            bool upFlag=false;
            if(pm==100||pe==100||pj==100)res='A';
            else if((pm+pe)/2.0>=90)res='A';
            else if(ave>=80)res='A';
            else if(ave>=70){
                res='B';
                upFlag=true;
            }
            else if(ave>=50&&(pm>=80||pe>=80)){
                res='B';
                if(upFlag)res='A';
            }
            else res='C';
            cout<<res<<endl;
        }
    }
}

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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    while (n--) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      if (pm == 100 || pe == 100 || pj == 100 || pm+pe >= 180 || pm+pe+pj >= 240)
	cout << "A" << endl;
      else if (pm+pe+pj >= 210 || (pm+pe+pj >= 50 && (pm >= 80 || pe >= 80)))
	cout << "B" << endl;
      else
	cout << "C" << endl;
    }
  }
  return 0;
}