View Code of Problem 30

#include <string.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
#pragma warning(disable:4996)


int main() {
	int n;
	int x = 0;
	while (scanf("%d", &n) != EOF) {
		for (int i = 1; i <= n; i++) {
			x += i;
		}
		printf("%d\n", x);
	}
	return 0;
}	
/*
Main.cc:5:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 ^
Main.cc: In function 'int main()':
Main.cc:11:23: error: 'scanf' was not declared in this scope
  while (scanf("%d", &n) != EOF) {
                       ^
Main.cc:11:28: error: 'EOF' was not declared in this scope
  while (scanf("%d", &n) != EOF) {
                            ^
Main.cc:15:19: error: 'printf' was not declared in this scope
   printf("%d\n", x);
                   ^
*/

Double click to view unformatted code.


Back to problem 30