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

C++: #include <stdio.h>

void dividing_student(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100 || ((pm + pe) / 2 >= 90) || ((pm + pe + pj) / 3 >= 80)) {
        printf("A\n");
    }
    else if (((pm + pe + pj) / 3 >= 70) || (((pm + pe + pj) / 3 >= 50) && (pm >=80 || pe >= 80))) {
        printf("B\n");
    }
    else {
        printf("C\n");
    }
}

int main(void)
{
    int n, pm, pe, pj;
    scanf("%d", &n);
    while (n != 0) {
        for (int i = 0; i < n; ++i) {
            scanf("%d %d %d", &pm, &pe, &pj);
            dividing_student(pm, pe, pj);
        }    
        scanf("%d", &n);
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int n,m,e,j,i,cls[10000],flg;
	while(1){
		scanf("%d",&n);
		if(n<=0)break;
		for(i=0;i<n;i++){
			flg=0;
			scanf("%d %d %d",&m,&e,&j);
			if((m==100||e==100||j==100)||(m+e)/2>=90||(m+e+j)/3>=80){
				cls[i]=1;
				flg=1;
			}
			if((m+e+j)/3>=70){
				flg++;
				cls[i]=2;
			}
			if((m+e+j)/3>=50&&(m>=80||e>=80)){
				flg++;
				cls[i]=2;
			}
			if(flg>=2){
				cls[i]=1;
			}
			if(flg==0){
				cls[i]=3;
			}
		}
		for(i=0;i<n;i++){
			if(cls[i]==1){
				printf("A\n");
			}
			if(cls[i]==2){
				printf("B\n");
			}
			if(cls[i]==3){
				printf("C\n");
			}
		}
	}
	return 0;
}