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>
#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 <iostream>

using namespace std;

int main(void){

  int n;
  while( cin >> n , n ){

    while(n--){

      int pm,pe,pj;
      cin >> pm >> pe >> pj;

      if( pm == 100 || pe == 100 || pj == 100 ){
	cout << "A" << endl;
	continue;
      }
      if( (pm + pe) / 2 >= 90 ){
      	cout << "A" << endl;
	continue;
      }
      if( ( pm + pe + pj ) / 3 >= 80 ){
	cout << "A" << endl;
	continue;
      }
      if( ( pm + pe + pj ) / 3 >= 70 ){
	cout << "B" << endl;
	continue;
      }
      if( ( pm + pe + pj ) / 3 >= 50 && ( pm >= 80 || pe >= 80 ) ){
	cout << "B" << endl;
	continue;
      }
      cout << "C" << endl;
    }
  }
  return 0;
}

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

char judgeScore(int, int, int);

int main(void)
{
    int amount_student, score_math, score_eng, score_jpn;

    while (true) {
        scanf("%d", &amount_student);
        
        if (amount_student == 0) {
            break;
        }
        
        for (int num_student = 0; num_student < amount_student; num_student++) {
            scanf("%d%d%d", &score_math, &score_eng, &score_jpn);
            printf("%c\n", judgeScore(score_math, score_eng, score_jpn));  
        }
    }
    
    return 0;
}

char judgeScore(int x, int y, int z)
{
    int average_all = (x + y + z) / 3; //切り捨てが起こっても大丈夫
    if (x == 100 || y == 100 || z == 100) {
        return 'A';
    } else if ((x+y) / 2 >= 90) {
        return 'A';
    } else if (average_all >= 80) {
        return 'A';
    } else if (average_all >= 70) {
        return 'B';
    } else if (average_all >= 50 && (x >= 80 || y >= 80)) {
        return 'B';
    } else {
        return 'C';
    }
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,a1,a2,a3,i,sum=0,avg=0;
	while(1){
		cin>>a;
		if(a==0) break;
		for(i=0;i<a;i++){
			cin>>a1>>a2>>a3;
			sum=a1+a2+a3;
			avg=sum/3;
			if(a1==100||a2==100||a3==100||avg>=80||(a1+a2)/2>=90||avg>=50&&a1>=80&&a2>=80||avg>=70&&a1>=80||avg>=70&&a2>=80)
				cout<<'A'<<endl;
			else if(avg>=70||avg>=50&&a1>=80||avg>=50&&a2>=80)
				cout<<'B'<<endl;
			else
				cout<<'C'<<endl;
		}
	}
	return 0;
}

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

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

#define pb push_back
#define in ,
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  while(cin >> n) {
    if(!n) return 0;
    rep(i, 0, n) {
      int s, e, k;
      cin >> s >> e >> k;
      if(s == 100 || e == 100 || k == 100 || (s + e) / 2 >= 90 || (s + e + k) / 3 >= 80) cout << 'A' << endl;
      else if((s + e + k) / 3 >= 70 || ((s + e + k) / 3 >= 50 && (s >= 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 ave;
    while (true) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        } else {
            for (int i = 0; i < n; ++i) {
                scanf("%d %d %d", &pm, &pe, &pj);
                ave = (pm + pe + pj) / 3;
                if (pm == 100 || pe == 100 || pj == 100) {
                    printf("A\n");
                } else if ((pm + pe) / 2 >= 90) {
                    printf("A\n");
                } else if (ave >= 80) {
                    printf("B\n");
                } else if (ave >= 50 && (pm >= 80 || pe >= 80)) {
                    printf("B\n");
                } else {
                    printf("C\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<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;
				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;
}

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

C++: #include<stdio.h>

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

int main(void)
{
    while(1){
        int n;/*nはデータの個数*/
        scanf("%d", &n);    
        if(n == 0){
            break;
        }else{
            for( int i = 0; i < n; ++i){
                int pm ,pe, pj; /*左から数学、英語、国語の点数*/
                scanf("%d %d %d", &pm, &pe, &pj);
                dividing_student( pm, pe, pj);
            }
        }
    }
    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 >= 80 || b >= 80)){
        printf("B\n");
    }else{
        printf("C\n");
    }
}