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<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
  int n,pm[10005],pe[10005],pj[10005];

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

  return 0;
}

C++: #include <iostream>

using namespace std;

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

C++: #include<stdio.h>
int main(void) {
	int n;
	int i,m,e,j;
	while(1){
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d%d%d",&m,&e,&j);
			if(m==100||e==100||j==100){
				printf("A\n");
			}else if(m+e>=180){
				printf("A\n");
			}else if(m+e+j>=240){
				printf("A\n");
			}else if(m+e+j>=210){
				printf("B\n");
			}else if(m+e+j>=150&&(m>=80||e>=80)){
				printf("B\n");
			}else{
				printf("C\n");
			}
		}
	}
	return 0;
}

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((students[n][0]+students[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(students[i][0],i)<<endl;
    }
  }
  return 0;
}

C++: /*
    2014.07.04 1259~1310
    C language Lecture week ∞
*/

#include <stdio.h>
#include <string.h>

char classify ( int score_math, int score_eng, int score_jpn );

int main (void) {
    
    int score_math = -1;
    int score_eng = -1;
    int score_jpn = -1;
    
    int max = -1;
    
    while (1) {
        
        scanf ( "%d", &max );
        
        if ( max == 0 ) {
            break;
        }
        
        for ( int cnt = 0; cnt < max; cnt ++ ) {
            scanf ( "%d", &score_math );
            scanf ( "%d", &score_eng );
            scanf ( "%d", &score_jpn );
            printf ( "%c\n", classify ( score_math, score_eng, score_jpn ) );
        }
    
    }
    
    return 0;
    
}

char classify ( int score_math, int score_eng, int score_jpn ) {
    char out;
    int score_me = ( score_math + score_eng );
    int score_mej = ( score_math + score_eng + score_jpn );
    
    if ( score_math == 100 || score_eng == 100 || score_jpn == 100 ) {
        out = 'A';
    } else if ( score_me >= 180 ) {
        out = 'A';
    } else if ( score_mej >= 240 ) {
        out = 'A';
    } else if ( score_mej >= 210 ) {
        out = 'B';
    } else if ( score_mej >= 150 && ( score_math >= 80 || score_eng >= 80 ) ) {
        out = 'B';
    } else {
        out = 'C';
    }
    
    return out;
}

C++: #include<stdio.h>
int main(void)
{
    int n,pm,pe,pj,i,s,d;
	scanf("%d",&n);
	for (i=0;i<n;i++){
	    scanf("%d %d %d",&pm,&pe,&pj);
		s=(pm+pe)/2.0;
		d=(pm+pe+pj)/3.0;
		if (pm==100||pe==100||pj==100){
		    printf("A\n");
		}
		else if (s>=90||d>=80){
		    printf("A\n");
		}
		else if (d>=70){
		    printf("B\n");
		}
		else if (d>=50&&pm>=80||pe>=80){
		    printf("B\n");
		}
		else {
		    printf("C\n");
		}
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,pj,pm,pe;
	while(1){
		cin>>n;
		if(n==0) break;
		for(int i=1;i<=n;i++){
			cin>>pm>>pe>>pj;
			if(pm==100||pe==100||pj==100){
				cout<<"A"<<endl;

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

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

int main() {

  int n;
  while( cin >> n, n ) {
    for(int i=0; i<n; i++) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      int ave = (pm + pe + pj) / 3;
      
      if( pm == 100 || pe == 100 || pj == 100 ) cout << 'A' << endl;
      else if( (pm + pe) / 2 >= 90 ) cout << 'A' << endl;
      else if( ave >= 80 ) cout << 'A' << endl;
      else if( ave >= 70 ) cout << 'B' << endl;
      else if( ave >= 50 && ( pm >= 80 || pe >= 80 ) ) cout << 'B' << endl;
      else cout << 'C' << endl;
    }
  }
}

C++: #include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	int n,a,b,c;

	while(true){
		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 >= 180 || a+b+c >= 240){
				printf("A\n");
			}else if((a + b + c >= 210) || (a+b+c>=150 && (a >= 80 || b >= 80))){
				printf("B\n");
			}else{
				printf("C\n");
			}
		}

	}
    return 0;
}

C++: #include <iostream>

int value (int pm, int pe, int pj);
int main()
{
    int N;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
    int pm, pe, pj;	       
    std::cin >> pm >> pe >> pj;
    if (value (pm, pe, pj) == 1) {
        std::cout << "A" <<std::endl;
        } else if (value (pm, pe, pj) == 2) {
        std::cout << "B" <<std::endl;
        } else {
        std::cout << "C" <<std::endl;
        }
    }
    return 0;
}

int value(int pm, int pe, int pj)
{
    if (pm == 100 || pe == 100 || pj == 100) {
    return 1;
    } else if (pm + pe >= 180) {
    return 1;
    } else if (pm + pe + pj >= 240) {
    return 1;
    } else if (pm + pe + pj >= 210) {
    return 2; 
    } else if (pm + pe + pj >= 150 && (pm >= 80 || pe >=80) ) {
    return 2;
    }else {
    return 3;
    }
}