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 divide(int, int, int);

int main(void)
{
	int n;
	scanf("%d", &n);
	int grade[n][3];
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &grade[i][0], &grade[i][1], &grade[i][2]);
		divide(grade[i][0], grade[i][1], grade[i][2]);
	}
	return 0;
}

int divide(int m, int e, int j)
{
	if (m == 100 || e == 100 || j == 100 ||
		(m + e) / 2 >= 90 ||
		(m + e + j) / 3 >= 80) {
		printf("A\n");
	} else if ((m + e + j) / 3 >= 70 ||
		       ((m + e + j) / 3 >= 50 && (m > 80 || e > 80))) {
		printf("B\n");
	} else {
		printf("C\n");
	}
	return 0;
}

C++: #include<stdio.h>

void dividing(int pm, int pe, int pj);

int main(void)
{
  int n, pm, pe, pj;
  int i;
  while (1) {
  scanf("%d", &n);
  if (n == 0) {
    break;
  } else {
  while (i < n) {
    scanf("%d %d %d", &pm, &pe, &pj);
    dividing(pm, pe, pj);
    i++;
  }
  }
  }
  return 0;
}

void dividing(int pm, int pe, int 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 && (pm > 80 || pe > 80)){
    printf("B\n");
  } else {
    printf("C\n");
  }
}

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n;
	
	while (cin >> n, n) {
		for_(i,0,n) {
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			
			double ave = (double)(pm + pe + pj) / 3.;
			double aveme = (double)(pm + pe) / 2.;
			
			if (aveme > 89 || pm == 100 || pe == 100 || pj == 100) {
				cout << "A" << endl;
			} else {
				
				if (ave < 50) {
					cout << "C" << endl;
				} else if (ave < 70) {
					if (pm >= 80 || pe >= 80) cout << "B" << endl;
					else cout << "C" << endl;
				} else if (ave < 80) {
					cout << "B" << endl;
				} else {
					cout << "A" << endl;
				}
			}
		}
	}
}

C++: #include <stdio.h>

void dividing(int pm, int pe, int pj);

int main(void)
{
    int number;
    scanf("%d\n", &number);    
    while (number != 0) {
        int pm[number];
        int pe[number];
        int pj[number];
        for (int i = 0; i < number; ++i) {
            scanf("%d %d %d", &pm[i], &pe[i], &pj[i]);
            dividing(pm[i], pe[i], pj[i]);
        }
        scanf("%d", &number);
    }
}
void dividing(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
        printf("A\n");
        return;
    }
    if ((pm + pe) / 2 >= 90) {
        printf("A\n");
        return;
    }
    if ((pm + pe + pj) / 3 >= 80) {
        printf("A\n");
        return;
    }
    if ((pm + pe + pj) / 3 >= 70) {
        printf("B\n");
        return;
    }
    if (((pm + pe + pj) / 3 >= 50) && (pm >= 80 || pe >= 80)) {
        printf("B\n");
        return;
    }
    printf("C\n");
    return;
}

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

int main()
{
  int n;
  while (cin >> n && n != 0){
    while (n--){
      int a, b, c;
      cin >> a >> b >> c;
      if (a == 100 || b == 100 || c == 100){
        cout << 'A' << endl;
        continue;
      }
      if (a + b >= 180){
        cout << 'A' << endl;
        continue;
      }
      if (a + b + c >= 240){
        cout << 'A' << endl;
        continue;
      }
      if (a + b + c >= 210){
        cout << 'B' << endl;
        continue;
      }
      if (a + b + c >= 150 && (a >= 80 || b >= 80)){
        cout << 'B' << endl;
        continue;
      }
      cout << 'C' << endl;
    }
  }
}

C++: #include <iostream>
using namespace std;
int main(void){
    int n,a,b,c;
    while (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 ) cout << "B" <<endl;
    else if ((a+b+c)/3>=50 && b >=80 ) cout << "B" <<endl;
    else cout << "C" <<endl;   
    }
    }
}

C++: // AOJ 0218
#include<iostream>

int main()
{
	int n, pm, pe, pj;
	while( std::cin >> n, n )
	{
		int rank;
		for( int i = 0; i != n; ++i )
		{
			std::cin >> pm >> pe >> pj;
			int ave = ( pm + pe + pj ) / 3;

			if( pm == 100 || pe == 100 || pj == 100 )
				rank = 0;
			else if( ( pm + pe ) / 2 >= 90 )
				rank = 0;
			else if( ave >= 80 )
				rank = 0;
			else if( ave >= 70 )
				rank = 1;
			else if( ave >= 50 && ( pm >= 80 || pe >= 80 ) )
				rank = 1;
			else
				rank = 2;

			std::cout << (char)('A' + rank) << std::endl;
		}
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctype.h>

const int INF =100000000;

using namespace std;

int main(){

  while(1){

    int n;

    cin >> n;

    if(n == 0){
      break;
    }else{
    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 && b >= 80){
	cout << "B" << endl;
      }else if(a+b+c >= 150 && a >= 80){
	cout << "B" << endl;
      }else{
	cout << "C" << endl;
      }
    }
    }
  }
}

C++: #include<iostream>

using namespace std;

int main(){
	while(true){
		int N;
		cin >> N;
		if (N == 0) break;
		int count = 0;
		bool na =true;
		for (int i = 0; i < N; i++){
			int k;
			cin >> k;
			if(k > 1)
				na = false;
			if (k > 0)
				count++;
		}
		if (na == true)
			cout << "NA" <<endl;
		else
			cout << count + 1 << endl;
	}
  return 0;
}

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

int main()
{
	int n;
	int pm, pe, pj, ave1, ave2;
	while (true)
	{
		cin >> n;
		if (n == 0)
		{
			break;
		}

		for (int i = 1; i <= n; i++)
		{
			cin >> pm >> pe >> pj;
		}
		ave1 = (pm + pe + pj) / 3;
		ave2 = (pm + pe) / 2;

		if (ave1 >= 80 )
		{
			cout << "A" << endl;
		}

		if (ave2 >= 90)
		{
			cout << "A" << endl;
		}

		if (pm == 100 || pe == 100 || pj == 100)
		{
			cout << "A" << endl;
		}

		if (ave1 >= 70)
		{
			cout << "B" << endl;
		}


		if (ave1 >= 50 && pm >= 80 || pe >= 80)
		{
			cout << "B" << endl;
		}

		else
		{
			cout << "C" << endl;
		}

	}
}

C++: #include<iostream>

char *c;
int n,pm,pe,pj;

char solve(int m, int e, int j){
	char ans='C';
	if(m==100 || e==100 || j==100 || m+e>=180 || m+e+j>=240)
		ans = 'A';
	else if(m+e+j>=210 || (m+e+j>=150 && (m>=80 || e>=80)))
		ans = 'B';
	return ans;
}

int main(){
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		c = new char[n];
		for(int i=0; i<n; i++){
			std::cin >> pm >> pe >> pj;
			c[i] = solve(pm, pe, pj);
		}
		for(int i=0; i<n; i++)
			std::cout << c[i] << endl;
		delete[] c;
	}
	return 0;
}