[Plain] Description
Calculate S = 1 + (1 + 2) + (1 + 2 + 3) +... + (1 + 2 +... + N ). If N is known, write the program to find S.
Input
The first line has an integer T, indicating that there are T groups of test data. Line 2 ~ Row T + 1 has 1 integer N, 1 <= N <= 200.
Output
For each group of input data, the output line contains an integer, that is, the value of S.
Sample Input
2
1
200
Sample Output
1
1353400
Description
Calculate S = 1 + (1 + 2) + (1 + 2 + 3) +... + (1 + 2 +... + N ). If N is known, write the program to find S.
Input
The first line has an integer T, indicating that there are T groups of test data. Line 2 ~ Row T + 1 has 1 integer N, 1 <= N <= 200.
Output
For each group of input data, the output line contains an integer, that is, the value of S.
Sample Input
2
1
200
Sample Output
1
1353400
[Plain] # include <stdio. h>
Int SUM (int num );
Int main ()
{
Int I;
Int n;
Int num;
Int sum;
Scanf ("% d", & n );
While (n --)
{
Scanf ("% d", & num );
Sum = 0;
For (I = 1; I <= num; I ++)
{
Sum + = SUM (I );
}
Printf ("% d", sum );
If (n> 0)
{
Printf ("\ n ");
}
}
Return 0;
}
Int SUM (int num)
{
Int I;
Int sum = 0;
For (I = 1; I <= num; I ++)
{
Sum + = I;
}
Return sum;
}
# Include <stdio. h>
Int SUM (int num );
Int main ()
{
Int I;
Int n;
Int num;
Int sum;
Scanf ("% d", & n );
While (n --)
{
Scanf ("% d", & num );
Sum = 0;
For (I = 1; I <= num; I ++)
{
Sum + = SUM (I );
}
Printf ("% d", sum );
If (n> 0)
{
Printf ("\ n ");
}
}
Return 0;
}
Int SUM (int num)
{
Int I;
Int sum = 0;
For (I = 1; I <= num; I ++)
{
Sum + = I;
}
Return sum;
}