Home > Back-end >  Everybody, help to see see!
Everybody, help to see see!

Time:11-07

CodePudding user response:

 
Void ChongDongDeHua1 (void)
{
Int nInit=1;
Int nNum [3]={0, 0, 0};

Printf (" input hours: ");

Int nHour=0;
Scanf_s (" % d ", & amp; NHour);

For (int I=0; I & lt; NHour; + + I)
{
If (I==0)
{
NNum [I]=nInit;
}
The else
{
NNum [2] +=nNum [1].
NNum [1]=nNum [0];
NNum [0]=nNum [2];
}
}

Int nTotal=nNum nNum [0] + [1] + nNum [2].

Printf (" output virus count: % d \ r \ n ", nTotal);
}

Void ChongDongDeHua2 (void)
{
Int nSampleMax=20;
Printf (" % d most children \ r \ n ", nSampleMax);

Int * pSample=new int [nSampleMax];

Int nInput=0;
Int nTotal=0;
Int nSampleCount=0;

While (true)
{
Scanf_s (" % d ", & amp; NInput);

If (nInput==1)
break;

If (nSampleCount & gt;=nSampleMax)
{
The delete [] pSample;
Printf (" input error, most % d a kid \ r \ n ", nSampleMax);
return;
}

PSample [nSampleCount++]=nInput;
NTotal +=nInput;
}

If (nTotal % 2==0)
{
Int nLoopCount=nSampleCount/2;
Int * pID=new int [nLoopCount];

For (int I=0; I & lt; NLoopCount; + + I)
{
Int nSelect=I + 1;
Int nAddID=0;

PID [nAddID]=0;

While (pID [0] + nSelect & lt;=nSampleCount)
{
Int nPreAddID=nAddID;
While (nAddID + 1 & lt; NSelect & amp; & PID + 1 [nAddID] {
PID=pID [nAddID] [nAddID + 1] + 1;
+ + nAddID;
}

If (nAddID + 1 & lt; NSelect)
{
NAddID=nPreAddID;
}
The else
{
Int nSubTotal=0;
for (int j=0; J & lt; NSelect; + + j)
{
NSubTotal +=pSample [pID] [j];
}

For (int j=pID [nAddID]; J & lt; NSampleCount; + + j)
{
NSubTotal -=pSample [pID [nAddID]].
PID [nAddID]=j;
NSubTotal +=pSample [pID [nAddID]];

If (nSubTotal==nTotal/2)
{
Printf (" can divide: Yes \ r \ n ");

Printf (" combination results: ");
For (int k=0; K & lt; NSelect; + + k)
{
Printf (" % d ", pSample [pID [k]]).
}

Printf (" \ r \ n ");

The delete [] pSample;
The delete [] pID;

return;
}
}
}

If (nAddID==0)
+ + pID [nAddID];
The else
+ + pID [-- nAddID];
}
}
}

The delete [] pSample;

Printf (" can divide: No \ r \ n ");
}