Home > Back-end >  Perfect application for help
Perfect application for help

Time:11-23

2, known the Fibonacci sequence in the first few number 1,1,2,3,5,8,13 respectively, and the... , the programming for the sequence of the first n (n>
=5),
The input description
A line of an integer n (n>=5 and n
=100)
The output shows that
Every five line, also a line of less than 5

The input sample
5

The output sample
1 1 2 3 5

The code
#include
using namespace std;
Int main ()
{
Int n, I, a, [100].
A [0]=1;
A [1]=1;
Cin & gt;> n;
For (I=2; i{
A [I]=a [I - 1) + a (I - 2),
}
For (I=0; I & lt; n; I++)
{
Cout & lt; If (I % 5==4)
{
Cout & lt; }
}
return 0;
}

There is wrong

CodePudding user response:

There is no wrong, in fact you run it

CodePudding user response:

Because this is the topic of my in a game, the final checking their score is an empty system said I was wrong, but did not say where is wrong

CodePudding user response:

The last line is less a line break? Topic request of less than 5 a line, so in return 0; Need to print a newline before

CodePudding user response:

Test, should be more than an int type, when n> 45, has turned negative

 int main () {
Int n=100,=1 a1, a2=1, I, j;
Printf (" 1 1 ");
For (I=2, j=0; iIf (I % 5==0) printf (" \ n ");
A2=a1 + a2;
A1=a2 - a1;
Printf (" % d ", a2);
If (a2 & lt; 0 & amp; & J j=I==0);//record cross-border I
}
Printf (" \ n \ n % d ", j);//print why I value started crossing the line
}

CodePudding user response:

#include
using namespace std;
Int main ()
{
Int n, I, a, [100].
A [0]=1;
a [1]=1;
Cin & gt;> n;
For ( I=2; i
){
a [I]=a [I - 1) + a (I - 2),
}
For (I=0; I & lt; n; I++)
{
Cout & lt; a [I] & lt; <"";
If ( I % 5==4 )
{
Cout & lt; }
}
return 0;
}

CodePudding user response:

Bold is empty

CodePudding user response:

reference 4 floor qybao response:
test, should be more than an int type, when n> 45, has turned negative

 int main () {
Int n=100,=1 a1, a2=1, I, j;
Printf (" 1 1 ");
For (I=2, j=0; iIf (I % 5==0) printf (" \ n ");
A2=a1 + a2;
A1=a2 - a1;
Printf (" % d ", a2);
If (a2 & lt; 0 & amp; & J j=I==0);//record cross-border I
}
Printf (" \ n \ n % d ", j);//print why I value started crossing the line
}



Possible, but it defines partly subject has to come out, so should have nothing to do with the data range

CodePudding user response:

That estimate is finally a newline
If (I % 5==4 | | I==n - 1)//5 in a row or the last one

CodePudding user response:

Oh, it looks like the
  • Related