View Code of Problem 112

#include <iostream>
using namespace std;
int main(void){
	int c[10000];
	while(cin>>n){
		int total=0;
		if(!n) return 0;
		while(n--){
			cin>>a[n];
			total+=a[n];
		}
		cout<<total<<endl;
	}
	return 0;
}
/*
Main.cc: In function 'int main()':
Main.cc:5:13: error: 'n' was not declared in this scope
  while(cin>>n){
             ^
Main.cc:9:9: error: 'a' was not declared in this scope
    cin>>a[n];
         ^
Main.cc:4:6: warning: unused variable 'c' [-Wunused-variable]
  int c[10000];
      ^
*/

Double click to view unformatted code.


Back to problem 112