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>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n;
	while(cin >> n && n)
	{

		rep(i,n)
		{
	   		double	pm,pe,pj;
			cin >> pm >> pe >> pj;


			if(pm >= 100 || pe >= 100 || pj >= 100)
			{
				cout << "A" << endl;
			}
			else
			{
				double temp = pm + pe;
				temp /= 2;

		   		double temp2 = pm + pe + pj;
				temp2 /= 3;

				if(temp >= 90)
				{
					cout << "A" << endl;
				}
				else if(temp2 >= 80)
				{
					cout << "A" << endl;
				}
				else if(temp2 >= 70)
				{
					cout << "B" << endl;
				}
				else if(temp2 >= 50 && (pm >= 80 || pe >= 80))
				{
					cout << "B" << endl;
				}
				else cout << "C" << endl;
			}	
		}
	}
}

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

int main() {
    int n;
    while (cin >> n, n) {
        int pm, pe, pj;
        while (n--) {
            cin >> pm >> pe >> pj;
            if (pm == 100 || pe == 100 || pj == 100 ||
                (pm + pe) >= 180 || (pm + pe + pj) >= 240) {
                cout << "A";
            }
            else if (pm + pe + pj >= 210 ||
                     (pm + pe + pj >= 150 && (pm >= 80 || pe >= 80))) {
                cout << "B";
            }
            else {
                cout << "C";
            }
            cout << endl;
        }
    }
    return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int n, i, pm, pe, pj;

	while (1)
	{
		scanf("%d", &n);
		if (n == 0)break;
		for (i = 0;i < n;i++)
		{
			scanf("%d %d %d", &pm, &pe, &pj);
			if (pm == 100 || pe == 100 || pj == 100)
			{
				printf("A\n");
			}
			else if ((pm + pe) / 2 >= 90)
			{
				printf("A\n");
			}
			else if ((pm + pe + pj) / 3 >= 80)
			{
				printf("A\n");
			}
			else if ((pm + pe + pj) / 3 >= 70)
			{
				printf("B\n");
			}
			else if ((pm + pe + pj) / 3 >= 50)
			{
				if (pm >= 80 || pe >= 80)
				{
					printf("B\n");
				}
				else
				{
					printf("C\n");
				}
			}
			else
			{
				printf("C\n");
			}
		}

	}
	return 0;
}

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

int main(void)
{
    int n;
    int m, e, j;
    
    while (1){
        scanf("%d", &n);
        if (n == 0) break;
        
        for (int i = 0; i < n; i++){
            scanf("%d %d %d", &m, &e, &j);
            if ((m == 100) || (e == 100) || (j == 100)){
                printf("A\n");
            }
            else if (90 <= ((m + e) / 2.0)){
                printf("A\n");
            }
            else if (80 <= ((m + e + j) / 3.0)){
                printf("A\n");
            }
            else if (70 <= ((m + e + j) / 3.0)){
                printf("B\n");
            }
            else if ((50 <= ((m + e + j) / 3.0)) && ((80 <= m) || (80 <= e))){
                printf("B\n");
            }
            else {
                printf("C\n");
            }
        }
    }
    
    return (0);
}

C++: #include <iostream>

char DividingStudent(int pm, int pe, int pj)
{
    if (pm==100 || pm==100 || pj==100) {
        return 'A';
    } else if ((pm+pe)/2 >= 90){
        return 'A';
    } else if ((pm+pe+pj)/3 >= 80){
        return 'A';
    } else if ((pm+pe+pj)/3 >= 70){
        return 'B';
    } else if ((pm+pe+pj)/3 >= 50 && (pm>=80 || pe>=80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main()
{
    while(1){
        int n;
        std::cin >> n;
        if(n==0){
            return 0;
        }
        for (int i=0; i<n; i++) {
            int pm,pe,pj;
            std::cin >> pm >>pe >>pj;
            std::cout << DividingStudent(pm, pe, pj) << std::endl;
        }
    }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
char hyakuten(int *students[][3],int n){
  for(int i=0;i<3;i++){
   if(students[n][i]==100)return 'A';
  }
  if((students[n][0]+students[n][1])/2>=90)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=80)return 'A';
  if((students[n][0]+students[n][1]+students[n][2])/3>=70)return 'B';
  if((studnets[n][0]+studnets[n][1]+students[n][2])/3>=50&&students[n][0]>=80||students[n][1]>=80)return 'B';
  return 'C';
}


int main(){
  int n;
  while(cin>>n&&n){
    int students[10000][3];
    for(int i=0;i<n;i++){
      for(int j=0;j<3;j++){
        cin>>students[i][j];
      }
    }
    for(int i=0;i<n;i++){
      cout<<hyakuten(i)<<endl;
    }
  }
  return 0;
}

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

int main()
{
    int N;

    while ( cin >> N, N != 0 ) {
        for ( int i = 0; i < N; i++ ) {
            int a, b, c;
            cin >> a >> b >> c;
            if ( a + b + c >= 240 || a + b >= 180 || a == 100 || b == 100 || c == 100 ) {
                cout << "A" << endl;
            } else if ( a + b + c >= 210 || (a + b + c >= 150 && (a >= 80 || b >= 80)) ) {
                cout << "B" << endl;
            } else {
                cout << "C" << endl;
            }
        }
    }
    return ( 0 );
}

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

int main() {
	int n,pm,pe,pj;
	while(cin>>n,n){
		for(;n;--n){
			cin>>pm>>pe>>pj;
			
			int avr = pm+pe+pj;
			
			if(pm==100 || pe==100 || pj==100)cout<<"A";
			else if(pm+pe>=160)cout<<"A";
			else if(avr>=240)cout<<"A";
			else if(avr>=210)cout<<"B";
			else if(avr>=150 && (pm>=80||pe>=80))cout<<"B";
			else cout<<"C";
			
			cout<<endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>
 
void judge(int pe, int pm, int pj);
int main(void)
{
    int n, pe, pm, pj;
    while (1) {
        scanf("%d", &n);
        if (n == 0) {
            break;
        }
        for (int i = 0; i < n; ++i) {        
            scanf("%d %d %d", &pe, &pm, &pj);
            judge(pe, pm, pj);
        }
    }
}
void judge(int pe, int pm, int pj)
{
    int sum = pe + pm + pj;
    int sumem = pe + pm;
    bool flag2 = false;
    if (pm >= 80 || pe >= 80) {
        flag2 = true;
    }
    if (pe == 100 || pj == 100 || pm == 100 || sum >= 240 || sumem >= 180) {
        printf("A\n");
    } else if (sum >= 210) {
        printf("B\n");
    } else if (sum >= 150 && flag2 == true) {
        printf("B\n");
    } else {
        printf("C\n");
    }
}

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