杭电ACM 1001

C:

#include<stdio.h>
int main()
{
	long int n=0;
	while(scanf("%ld",&n)!=EOF)
	{
	
	    n=n%2?(n+1)/2*n:n/2*(n+1);
		printf("%ld\n\n",n);
	}
	return 0;
}


C++:

#include<iostream>
using namespace std; 
int main()
{
	long int n=0;
	while(cin>>n&&!cin.fail())
	{
	
	    n=n%2?(n+1)/2*n:n/2*(n+1);
		cout<<n<<endl<<endl;
	}
	return 0;
}


 

你可能感兴趣的:(编程,C++,c,ACM,杭电)