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 n,a,b,c,i,A,B;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a,&b,&c);  B=0;  A=0;
			if(a==100 || b==100 || c==100){
				printf("A\n");  A=1;
			}
			else if((a+b)/2>89){
				printf("A\n");  A=1;
			}
			else if((a+b+c)/3>79){
				printf("A\n");  A=1;
			}
			else if(A==0){
				if((a+b+c)/3>69)  B++;
				if((a+b+c)/3>49 && a>79 || b>79)  B++;
				if(B==2)  printf("A\n");
				else if(B==1)  printf("B\n");
			}
			if(A==0 && B==0)  printf("C\n");
		}
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(void)
{
	vector< vector<int> > p( 10000,vector<int>(3) );
	vector<char> ans(10000);
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		for(int i=0;i<n;i++){
			cin >> p[i][0] >> p[i][1] >> p[i][2];
			if(p[i][0]==100||p[i][1]==100||p[i][2]==100) ans[i]='A';
			else if(90*2<=p[i][0]+p[i][1]) ans[i]='A';
			else if(80*3<=p[i][0]+p[i][1]+p[i][2]) ans[i]='A';
			else if(70*3<=p[i][0]+p[i][1]+p[i][2]) ans[i]='B';
			else if(50*3<=p[i][0]+p[i][1]+p[i][2]&&(80<=p[i][0]||80<=p[i][1])) ans[i]='B';
			else ans[i]='C';
		}
		for(int i=0;i<n;i++) cout << ans[i] << endl; 
	}
	return 0;
}

C++: #include<stdio.h>
int main(void) {
	int n;
	int i,m,e,j;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d%d%d",&m,&e,&j);
			if(m==100||e==100||j==100){
				printf("A\n");
			}else if(m+e>=180){
				printf("A\n");
			}else if(m+e+j>=240){
				printf("A\n");
			}else if(m+e+j>=210){
				printf("B\n");
			}else if(m+e+j>=150&&(m>=80||e>=80)){
				printf("B\n");
			}else{
				printf("C\n");
			}
		}
	}
	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 > 1) printf("A\n");
            if(ans == 1) printf("B\n");
            if(ans == 0) printf("C\n");
       }
    }
    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;
      return grade;
    }
    if ((pm + pe) / 2 >= 90) {
      grade = 1;
      return grade;
    }
    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;
      return grade;
    } else {
      grade = 3;
      return grade;
    }
    return grade;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	int m[100] = {};
	int e[100] = {};
	int j[100] = {};
	char* rank[10000] = {};
	int i = 0;
	while (cin >> n) {

		for (int k = 0; k < n; k++) {
			cin >> m[k] >> e[k] >> j[k];
		}
		for (i; i < n; i++) {
			int s = (m[i] + e[i] + j[i]) / 3;
			if ((m[i] == 100)||(e[i] == 100)||(j[i] == 100)) {
				rank[i] = "A";
			}
			else if ((m[i] + e[i]) / 2 >= 90) {
				rank[i] = "A";
			}
			else if (s >= 80) {
				rank[i] = "A";
			}
			else if (s >= 70) {
				rank[i] = "B";
			}
			else if (s >= 50 && m[i] >= 80) {
				rank[i] = "B";
			}
			else {
				rank[i] = "C";
			}
		}
		if (n == 0)
			break;
	}
	for (int l = 0; l < i; l++) {
		cout << rank[l] << endl;
	}

	return 0;
	
}

C++: #include <stdio.h>

void dividing(int pm, int pe, int pj);

int main(void)
{
    int students_number;
    int pm[10000], pe[10000], pj[10000];
    scanf("%d", &students_number);
    while (1) {
        if (students_number == 0) {
            break;
        } else {
            for (int i = 0; i < students_number; ++i) {
                scanf("%d %d %d", &pm[i], &pe[i], &pj[i]);
            }
            for (int i = 0; i < students_number; ++i) {
                dividing(pm[i], pe[i], pj[i]);
            }
            scanf("%d", &students_number);
        }
    }
    return 0;
}

void dividing(int pm, int pe, int pj)
{
    char rank;
    if (pm == 100 || pe == 100 || pj == 100) {
        rank = 'A';
    } else if (pm + pe >= 90 * 2) {
        rank = 'A';
    } else if (pm + pe + pj >= 80 * 3) {
        rank = 'A';
    } else if (pm + pe + pj >= 70 * 3) {
        rank = 'B';
    } else if (pm + pe + pj >= 50 * 3 && (pm >= 80 || pe >= 80)) {
        rank = 'B';
    } else {
        rank = 'C';
    }
    printf("%c\n", rank);
}

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){
				cls[i]=1;
				flg++;
			}
			if((m+e)/2>=90){
				cls[i]=1;
				flg++;
			}
			if((m+e+j)/3>=80){
				cls[i]=1;
				flg++;
			}
			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<1){
				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;
}