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;	
	while(cin >> n,n){
		while(n--){
			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;
		}
	}
	return 0;
}

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 <stdio.h>

void class_judge(int math, int en, int ja);

int main(void)
{
	int set, math, en, ja;
	while (1) {
		scanf("%d", &set);
		if (set == 0) {
			break;
		} else {
			for (int i = 0; i < set; i++) {
				scanf("%d %d %d", &math, &en, &ja);
				class_judge(math ,en ,ja);
			}
		}
	}
	return 0;
}

void class_judge(int math, int en, int ja)
{
	if (math == 100 || en == 100 || ja == 100) {
		printf("A\n");
	} else if ((math + en) / 2 >= 90) {
		printf("A\n");
	} else if ((math + en + ja) / 3 >= 80) {
		printf("A\n");
	} else if ((math + en + ja) / 3 >= 70) {
		printf("B\n");
	} else if ((math + en + ja) / 3 >= 50 && (math >= 80 || en >= 80)){
		printf("B\n");
	} else {
		printf("C\n");
	}
}

C++: #include <stdio.h>

char divide(int math, int english, int japanese);
char grade;

int main(void)
{
    int dataset;
    int math, english, japanese;

    while (1){
        scanf("%d", &dataset);
        if (dataset == 0){
            break;
        } else {
            while (dataset--){
                scanf("%d %d %d", &math, &english, &japanese);
                grade = divide(math, english, japanese);
                printf("%c\n", grade);
            }
        }
    }

    return 0;
}

char divide(int math, int english, int japanese)
{
    int sum = math + english + japanese;

    if (math == 100 || english == 100 || japanese == 100){
        grade = 'A';
    } else if (math + english >= 90 * 2){
        grade = 'A';
    } else if (sum >= 80 * 3){
        grade = 'A';
    } else if (sum >= 70 * 3){
        grade = 'B';
    } else if (sum >= 50 * 3 && (math >= 80 || english >= 80)){
        grade = 'B';
    } else {
        grade = 'C';
    }

    return grade;
}

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

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

    if(n==0) break;
    
    int c[10]={};
    int v;
    
    for(int i=0;i<n;i++){
      cin>>v;
      c[v]++;
    }
    
    for(int i=0;i<10;i++){
      if(c[i]==0) cout<<"-"<<endl;
      else{
	for(int j=0;j<c[i];j++){
	  cout<<"*";
	}
	cout<<endl;
      }
    }
  }
  
  return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,pm,pe,pj;
	cin>>n;
	while(n){
		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++: // 2010/12/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int pm, pe, pj;
			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)&&(pm>=80||pe>=80))
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}

	return 0;
}

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(rep == 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>
#include<string>
using namespace std;
int main()
{
	int n;
	int m[100] = {};
	int e[100] = {};
	int j[100] = {};
	string rank[10000] = {};
	int g = 0;
	while (cin >> n&&n) {
		for (int k = 0; k < n; k++) {
			cin >> m[k] >> e[k] >> j[k];
		}
		for (int i = 0; i < n; i++) {
			int s = (m[i] + e[i] + j[i]) / 3;
			g++;
			if ((m[i] == 100)||(e[i] == 100)||(j[i] == 100)) {
				rank[i] = "A";
			}
			else if ((m[i] + e[i]) / 2 >= 90) {
				rank[i] = "A";
			}
			else if (s >= 80) {
				rank[i] = "A";
			}
			else if (s >= 70) {
				rank[i] = "B";
			}
			else if (s >= 50 && m[i] >= 80) {
				rank[i] = "B";
			}
			else {
				rank[i] = "C";
			}
			cout << rank[i] << endl;
		}

	}

	return 0;
	
}

C++: #include <cstdio>

int n;

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

C++: #include <stdio.h>

int main()
{
    int n;
    int math, eng, jap;

    while (scanf("%d", &n), n != 0) {
        for (int i = 0; i < n; i++) {
            scanf("%d %d %d", &math, &eng, &jap);

            if (math == 100 || eng == 100 || jap == 100) {
                puts("A");
            }
            else if ((math + eng) >= 180) {
                puts("A");
            }
            else if ((math + eng + jap) >= 240) {
                puts("A");
            }
            else if ((math + eng + jap) >= 210) {
                puts("B");
            }
            else if ((math + eng + jap) >= 150 &&
                     (math >= 80 || eng >= 80)) {
                puts("B");
            }
            else {
                puts("C");
            }
        }
    }

    return 0;
}