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

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

  int n;
  double 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;
    }
  }
  return 0;
}

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[i] > 1) printf("A\n");
            if(ans[i] == 1) printf("B\n");
            if(ans[i] == 0) printf("C\n");
       }
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
	int n;
	int i;
	char rank[10000];
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		
		int ans1,ans2=0;
		for(i=0;i<n;i++)
		{
			int pm,pe,pj;
			int hei;
			cin >> pm >> pe >> pj ;
			hei = (pe+pj+pm)/3;
			if(pm==100||pe==100||pj==100){
				rank[i] ='A';
			}
			else
			if((pe+pm)/2>=90){
				rank[i] ='A';
			}else
			if(hei>=80){
				rank[i] = 'A';
			}else
			if(hei>=70){
				rank[i] = 'B';
			}else
			if(hei>=50&&(pe>=80||pm>=80)){
				rank[i] = 'B';
			}else rank[i] = 'C';
		}
		for(i=0;i<n;i++){
			cout << rank[i] << endl;
		}
	}
}

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)) {
      grade = 2;
    } else {
      grade = 3;
      return grade;
    }
    return grade;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,i,j,pm[10000],pe[10000],pj[10000],flg;
	
	while(1){
		
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++) scanf("%d %d %d",&pm[i],&pe[i],&pj[i]);
		for(i=0;i<n;i++){
			flg=0;
			if(pm[i]==100 || pe[i]==100 || pj[i]==100) {
				printf("A\n");
				flg=1;
			}
			else if((double)(pm[i]+pe[i])/2>=90){
				printf("A\n");
				flg=1;
			}
			else if((double)(pm[i]+pe[i]+pj[i])/3>=80){
				printf("A\n");
				flg=1;
			}
			else if((double)(pm[i]+pe[i]+pj[i])/3>=70){
				printf("B\n");
				flg=1;
			}
			else if((double)(pm[i]+pe[i]+pj[i])/3>=50){
				if(pm[i]>=80 || pe[i]>=80){
					printf("B\n");
					flg=1;
				}
			}
			if(flg==0){
				printf("C\n");
			}
		}
	}
	return 0;
}

C++: #include <iostream>


void f(int pm, int pe, int pj)
{
	double ave = (pm + pe + pj) / 3;
	if (pm == 100 || pe == 100 || pj == 100) {
		std::cout << "A" << std::endl;
	} else if ((pm + pe) / 2 >= 90 || ave >= 80) {
		std::cout << "A" << std::endl;
	} else if (ave >= 70 && (pm >=80 || pe >= 80)) {
		std::cout << "A" << std::endl;
	} else if ( ave >= 70 && (pm < 80 && pe < 80)) {
			std::cout << "B" << std::endl;
	} else if (ave >= 50 && ave < 70 && (pm >= 80 || pe >= 80)) {
		std::cout << "B" << std::endl;
	} else {
		std::cout << "C" << std::endl;
	}
}
int main()
{
	int n;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		int pm;
		int pe;
		int pj;
		std::cin >> pm >> pe >> pj;
		f(pm, pe, pj);
	}
	return 0;
}

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

int main() {
	while (1) {
		int a;
		cin >> a;
		if (a == 0)break;
		for (int b = 0; b < a; b++) {
			int  c, d, e;
			cin >> c >> d >> e;
			if (c == 100 || d == 100 || e == 100)cout << "A" << endl;
			else if (c+d>179)cout << "A" << endl;
			else if(c+d+e>239)cout << "A" << endl;
			else if(c+d+e>209)cout << "B" << endl;
			else if((c+d+e>149)&&(c>79||d>79))cout << "B" << endl;
			else cout << "C" << endl;
		}
   }
}

C++: #include <stdio.h>
#include <stdbool.h>

char grading(int math, int english, int japanese)
{
    double average_math_and_english = (math + english) / 2;
    double average_total = (math + english + japanese) / 3;
    if (100 == math || 100 == english || 100 == japanese || average_math_and_english >= 90 || average_total >= 80) {
        return 'A';
    } else if (average_total >= 70 || (average_total >= 50 && (math >= 80 || english >= 80))) {
        return'B';
    } else {
        return 'C';
    }
}

int main(void)
{
    while(1){
        int student;
        scanf("%d", &student);
        if (0 == student) {
            return 0;
        } else {
            for(int i = 0; i < student; i++){
                int math;
                int english;
                int japanese;
                scanf("%d %d %d", &math, &english, &japanese);
                printf("%c\n", grading(math, english, japanese));
            }
        }
    }
}