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,i,a[101],b[101],c[101],s,ss,sss,z;
	z=0;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d",&a[n],&b[n],&c[n]);
			ss=a[n]+b[n]+c[n];
			s=ss/3;
			sss=(a[n]+b[n])/2;
			if(100==a[n] || 100==b[n] || 100==c[n]){
				printf("A\n");
				z=1;
			}
			else if(sss>=90){
				printf("A\n");
				z=1;
			}
			else if(s>=80){
				printf("A\n");
				z=1;
			}
			else if(s>=70){
				printf("B\n");
				z=1;
			}
			else if(s>=50){
				if(a[n]>=80 || b[n]>=80){
				printf("B\n");
				z=1;
				}
			}
			if(z==0){
				printf("C\n");
			}
		}
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int n;
  while( cin >> n,n ){
    for(int i = 0 ; i < n ; i++){
      double a,b,c;
      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 >= 80)cout << "A" <<endl;
      else if((a+b+c)/3 >= 70)cout << "B" <<endl;
      else if((a+b+c)/3 >= 50 && (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) && (pm + pe) / 2 < 90) {
      grade = 2;
    } else {
      grade = 3;
    }
    return grade;
}

C++: #include<iostream>

using namespace std;

int main(){
	for(int n;cin>>n,n;){
		while(n--){
			int m,e,j;	cin>>m>>e>>j;
			if(m==100 || e==100 || j==100)	cout<<'A'<<endl;
			else if(m+e>=180)	cout<<'A'<<endl;
			else if(m+e+j>=240)	cout<<'A'<<endl;
			else if(m+e+j>=210)	cout<<'B'<<endl;
			else if(m+e+j>=150 && (m>=80 || e>=80))	cout<<'B'<<endl;
			else	cout<<'C'<<endl;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
main(){
  int n,pm,pe,pj;
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>pm>>pe>>pj;
      if(pm==100||pe==100||pj==100||(pe+pm)/2>=90||(pe+pm+pj)/3>=80){
	cout<<'A'<<endl;
      }
      else if((pe+pm+pj)/3>=70||((pe+pm+pj)/3>=50&&(pe>=80||pm>=80))){
	cout<<'B'<<endl;
      }
      else{
	cout<<'C'<<endl;
      }
    }
  }
}

C++: #include<stdio.h>
int main(void)
{
	int n,pm,pe,pj;
	int a,b,c;
	
	while(1)
	{
		scanf("%d",&n);
		if(n==0)
		{
			break;
		}
		for(a=1;n>a;a++)
		{
		scanf("%d %d %d",&pm,&pe,&pj);
		b=pm+pe+pj;
		if(pm==100||pe==100||pj==100||(b/3)>=80||(pe+pm)/2>=90)
		{
		printf("A");
		}
		else if((b/3)>=70||((b/3)>=50&&(pe>=80||pm>=80)))
		{
		printf("B");
		}
		else
		{
		printf("C");
		}
		}
		
	
	}
	

	return 0;
}

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 >= 180){
        class = 'A';
    } else if (sum >= 160){
        class = 'A';
    } else if (sum >= 140){
        class = 'B';
    } else if (sum >= 100 && (pm >= 80 || pe >= 80)){
        class = 'B';
    } else {
        class = 'C';
    }

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

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

char grading(int x, int y, int z)
{    
    int sum2 = x + y;
    int sum3 = x + y + z;
    char rank;
    if(x == 100 || y == 100 || z == 100){
        rank = 'A';
    } else if (sum2 >= 180){
        rank = 'A';
    } else if (sum3 >= 240){
        rank = 'A';        
    } else if (sum3 >= 210){
        rank = 'B';        
    } else if (sum3 >= 150 && (x >= 80 || y >= 80)){
        rank = 'B';        
    } else {
        rank = 'C'; 
    }  
    return rank;     
}
    

int main(void)
{   
    int rep, ma, en, ja;
    char rank;
    while(true){
        scanf("%d", &rep);
        if(rep == 0){
            break;
        }
        for(int i = 0; i < rep; ++i){
            scanf ("%d%d%d", &ma, &en, &ja);
            rank = grading(ma, en, ja);
            printf("%c\n", rank);
        }
    }
    return 0;        
}

C++: #include<iostream>
using namespace std;
int main(){
	int ave = 0,meave = 0;
	while(true){
		int n;
		cin >> n;
		if(n == 0)break;
		for(int i = 0; i < n; i++){
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			ave = (pm + pe + pj) / 3;
			meave = (pm + pe) / 2;
			if(pm == 100 || pe == 100 || pj == 100){
				cout << "A" << endl;
			}
			else if(meave >= 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;
			}
		}
	}
}

C++: #include<stdio.h>
int main(void)
{
	int n,i,a[101],b[101],c[101],s,ss,sss,z;
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			z=0;
			scanf("%d %d %d",&a[n],&b[n],&c[n]);
			ss=a[n]+b[n]+c[n];
			s=ss/3;
			sss=(a[n]+b[n])/2;
			if(100==a[n] || 100==b[n] || 100==c[n]){
				printf("A\n");
				z=1;
			}
			else if(sss>=90){
				printf("A\n");
				z=1;
			}
			else if(s>=80){
				printf("A\n");
				z=1;
			}
			else if(s>=70){
				printf("B\n");
				z=1;
			}
			else if(s>=50){
				if(a[n]>=80 || b[n]>=80){
				printf("B\n");
				z=1;
				}
			}
			if(z==0){
				printf("C\n");
			}
		}
		scanf("%d",&n);
	}
	return 0;
}