Esempio n. 1
0
int main(){
  int sum = 0;
  int status;

  // loop until exit character received
  while (TRUE){
    status = get_input(&sum);
    if (TRUE == status){
      output_sum(sum);
    } else if (EXIT == status) {
      printf("Goodbye.\n");
      return 0;
    } else {
      // else FALSE, so keep looping
      printf("Bad input supplied.\n");
    }
  }
}
Esempio n. 2
0
int main()
{
	try {
		// read N - amount of numbers to calculate sum of
		int amount = read_amount();
		// read set of numbers
		vector<double> numbers = read_numbers();
		// output sum
		output_sum(calc_sum(numbers, amount), amount);
		// output diff numbers
		output_diff_vector(calc_diff_vector(numbers));
		
	} catch (exception& e) {
		cerr << e.what();
		return 1;
	} catch (...) {
		cerr << "Unknown error";
		return 2;
	}
}