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>
using namespace std;
int main() {
	int n, m, e, j, ans[10000000],an;
	an = 0;
	while(1) {
		cin >> n;
		if (n == 0) {
			goto b;
		}
		for (int i = 1; i <= n; i++) {
			an = an+1;
			cin >> m >> e >> j;
			if (m == 100 || e == 100 || j == 100) {
				ans[an] = 1;
				goto a;
			}
			if (m + e >= 180) {
				ans[an] = 1;
				goto a;
			}
			if(m+e+j>=240){
				ans[an] = 1; 
				goto a;
			}
			if (m + e + j >= 210) {
				ans[an] = 2;
				goto a;
			}
			if (m + e + j >= 150) {
				if (m >= 80 || e >= 80) {
					ans[an] = 2;
					goto a;
				}
			}
			ans[an] = 3;
		a:;
		}
	}
b:;
	for (int i = 1; i <= an; i++) {
		if (ans[i] == 1) {
			cout << "A" << endl;
		}
		if (ans[i] == 2) {
			cout << "B" << endl;
		}
		if (ans[i] == 3) {
			cout << "C" << endl;
		}
	}
}

C++: #include<stdio.h>

void dividing_student(int a, int b, int c);
void finish();

int main(void)
{
    int n;/*nはデータの個数*/
    scanf("%d", &n);
    for( int i = 0; i <= n; ++i){
        if (i < n){
            int pm ,pe, pj; /*左から数学、英語、国語の点数*/
            scanf("%d %d %d", &pm, &pe, &pj);
            dividing_student( pm, pe, pj);
        }else{
            finish();
        }
    
    }/*return 0 いるの？*/
}

void dividing_student( int a, int b, int c)
{
    if( a >= 100|| b >= 100 || c >=100){
        printf("A\n");
    }else if( (a + b) / 2 >= 90){
        printf("A\n");
    }else if( (a + b + c) / 3 >= 80){
        printf("A\n");
    }else if( (a + b + c) / 3 >= 70){
        printf("B\n");
    }else if((a + b + c) / 3 >= 50 && (a >= 50 || b >= 50)){
        printf("B\n");
    }else{
        printf("C\n");
    }
}    
    
void finish()
{
    int n;
    scanf("%d", &n);
    if( n == 0){
        return 0;
    }else{
        for( int i = 0; i <= n; ++i){
            if (i < n){
                int pm ,pe, pj; /*左から数学、英語、国語の点数*/
                scanf("%d %d %d", &pm, &pe, &pj);
                dividing_student( pm, pe, pj);
            }else{
                finish();
            }
         }
    }
}

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

int grading(int x, int y, int z, char rank)
{    
    int sum2 = x + y;
    int sum3 = x + y + z;
    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'; 
    }       
}
    

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

C++: #include <iostream>
char judge(int math, int eng, int jap);
 
int main()
{
    int n, pm, pe, pj;
    while (true) {
        std::cin >> n;
        if (n == 0) {
            break;
        }
 
        for (int i = 0; i < n; i++) {
            std::cin >> pm >> pe >> pj;
            std::cout << judge(pm, pe, pj) << std::endl;
        }
    }
     
    return 0;
}
 
char judge(int math, int eng, int jap)
{
    float two_ave = (math + eng) / 2;
    float all_ave = (math + eng + jap) / 3;
 
    if (math == 100 || eng == 100 || jap == 100) {
        return 'A';
    } else if (two_ave >= 90) {
        return 'A';
    } else if (all_ave >= 80) {
        return 'A';
    } else if (all_ave >= 70) {
        return 'B';
    } else if (all_ave >= 50 && (math >= 80 || eng >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
 
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  int m[10005],e[10005],j[10005];
  char cl[10005];
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++){
      cin>>m[i]>>e[i]>>j[i];
      int ave=(m[i]+e[i]+j[i])/3;
      if(max(max(m[i],e[i]),j[i])==100 || (m[i]+e[i])/2>=90 || ave>=80){
	cl[i]='A';
      }else if(ave>=70 || (ave>=50 && max(m[i],e[i])>=80)){
	cl[i]='B';
      }else{
	cl[i]='C';
      }
    }
    
    for(int i=0;i<n;i++){
      cout<<cl[i]<<"\n";
    }
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,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;

    }
  }
}

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

int main(void)
{
    int n;
    int pm, pe, pj;
    int i;
    int sum;
    while (true) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            for (i = 0; i < n; ++i) {
                scanf("%d %d %d", &pm, &pe, &pj);
                sum = pm + pe + pj;
                if (pm == 100 || pe == 100 || pj == 100) {
                    printf("A\n");
                } else if (pm + pe >= 180) {
                    printf("A\n");
                } else if (sum >= 240) {
                    printf("A\n");
                } else if (sum >= 210) {
                    if (pm >= 80 || pe >= 80) {
                        printf("A\n");
                    } else {
                        printf("B\n");
                    }
                } else if (sum >= 150) {
                    if (pm >= 80 || pe >= 80) {
                        printf("B\n");
                    } else {
                        printf("C\n");
                    }
                } else {
                    printf("C\n");
                }
            }
        }
    }
    return 0;
}

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

int main()
{
    int n, a, b, c;
    for (; ;) {
        scanf("%d", &n);
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            scanf("%d %d %d", &a, &b, &c);
            if ((a == 100 || b == 100 || c == 100) || ((a + b)/2 >= 90) || ((a+b+c)/3 >= 80)) printf("A\n");
            else if (((a+b+c)/3 >= 70) || ((a+b+c)/3 >= 50 && (a >= 80 || b >= 80))) printf("B\n");
            else printf("C\n");
        }
    }
    return 0;
}