Home > Back-end >  Intelligence grand prix
Intelligence grand prix

Time:01-27

why input data, did not return results?

Input format:
Only one line, there is an integer N, I said to the layer number of the triangle (N
=45000)
The output format:
There are two lines, the first line is only a number, said the number of small triangle: the second industry is only a number, say the number of bars

Input the sample:
8
The output sample:
64
108
 # include "stdio.h" 


Int bian (int n);
Int di (int n);
Int main ()
{
int n;
The scanf (" % d ", & amp; N);
Printf (" % d % d \ n ", n * n, bian (n) + di (n));
return 0;
}


Int bian (int n)
{
int sum=0;
Int CNT=1;
If (n==1)
return 2;
The else
{
For (int I=2; CNT & lt;=n; I *=2)
sum +=i;
cnt++;
}
return sum;
}

Int di (int n)
{
int sum=0;
Int CNT=1;
For (int I=1; CNT & lt;=n; I++)
{
sum +=i;
cnt++;
}
return sum;

}
  • Related