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>

void divide(int math, int english, int japanese);

int main(void)
{
    int dataset;
    int math, english, japanese;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &math, &english, &japanese);
                divide(math, english, japanese);
            }
        }
    }

    return 0;
}

void divide(int math, int english, int japanese)
{
    int sum = math + english + japanese;

    if (math == 100 || english == 100 || japanese == 100){
        printf("A\n");
    } else if (math + english >= 90 * 2){
        printf("A\n");
    } else if (sum >= 80 * 3){
        printf("A\n");
    } else if (sum >= 70 * 3){
        printf("B\n");
    } else if (sum >= 50 * 3 && (math >= 80 || english >= 80)){
        printf("B\n");
    } else {
        printf("C\n");
    }
}

C++: #include<stdio.h>
int main(void)
{
	int n,m,e,j,i,cls[10000],flg;
	while(1){
		scanf("%d",&n);
		if(n<1)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;
			}
			else if(m+e>=90*2){
				cls[i]=1;
			}
			else if(m+e+j>=80*3){
				cls[i]=1;
			}
			else if(m+e+j>=70*3){
				cls[i]=2;
			}
			else if(m+e+j>=50*3&&(m>=80||e>=80)){
				cls[i]=2;
			}
			else 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;
}

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

void dividing_student (void)
{ 
    int math, english, japanese;
    scanf("%d %d %d", &math, &english, &japanese);
    if (math == 100 || english == 100 || japanese == 100) {
        printf("A\n");
    } else if (math + english >= 180) {
        printf("A\n");
    } else if (math + english + japanese >= 240) {
        printf("A\n");
    } else if (math + english + japanese >= 210) {
        printf("B\n"); 
    } else if (math + english + japanese >= 150 && (math >= 80 || english >= 80)) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

int main(void)
{
    while (true) {
        int n;
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        int i;
        for (i = 0; i < n; ++i) {
            dividing_student();
        }
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
   int n, pm1, pe1, pj1;
   while(true){
       cin >> n;
       if(n == 0){
           break;
       }
       for(int i = 0; i < n; i++){
           cin >> pm1 >> pe1 >> pj1;
           if(pm1==100 || pe1==100 || pj1==100){
               cout << "A" << endl;
           }
           else if((pm1+pe1)/2 >= 90){
               cout << "A" << endl;
           }
           else if((pm1+pe1+pj1)/3 >= 80){
               cout << "A" << endl;
           }
           else if((pm1+pe1+pj1)/3 >= 70){
               cout << "B" << endl;
           }
           else if((pm1+pe1+pj1)/3 >= 50 && (pm1>=80 || pe1>=80)){
               cout << "B" << endl;
           }
           else{
               cout << "C" << endl;
           }
       }
   }
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){

  int n,a,b,c;
  
  while(1){
  
    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)/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 || (a+b+c)/3 >= 50 && b >= 80){
	cout<<"B"<<endl;
      }else{
	cout<<"C"<<endl;
      }
    }
  }
  
    return 0;
}

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

static const double eps = 1e-8;

int getAvr(int* p,int n){
	int sum = 0;
	for(int i=0;i<n;i++){
		sum += p[i];
	}

	return sum/3;
}

int main(){
	int n;	
	while(~scanf("%d",&n)){	
		if(n==0) break;
		
		for(int i=0;i<n;i++){
			int p[3];
			//math,english,japanese			
			scanf("%d %d %d",p,p+1,p+2);

			for(int i=0;i<3;i++){
				if(p[i]==100){
					printf("A\n");
					goto next;
				}
			}

			if(p[0] + p[1] >= 180 || getAvr(p,3) >= 80){
				printf("A\n");
			}

			else if(getAvr(p,3) >= 70
				|| (getAvr(p,3) >= 50 && (p[0] >= 80 || p[1] >= 80))){
				printf("B\n");
			}

			else{
				printf("C\n");
			}
next:;

		}
		
	}
}

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

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

  int n,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+1)/2;
	if(total>=90)break;
	total=student.Math+student.English+student.Japanese;
	total=(total+1)/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<iostream>
#include<cstdio>
using namespace std;

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

  int n,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+1)/2;
	if(total>=90)break;
	total=student.Math+student.English+student.Japanese;
	total=(total+1)/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 <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	int n;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			int a, b, c;
			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;
}