Home > Back-end >  Strives for the big help, written in c language
Strives for the big help, written in c language

Time:11-30

CodePudding user response:

This question is worth 20 points, more may be someone

CodePudding user response:

reference 1st floor TorresFans response:
this problem is worth 20 points, more may be someone to




Not points, the first topic is the screenshot, followed by work, finally also does not have the code, call us to do, but this is not the first time he send the homework bosses to help capture the==every time is o...
I think watching convenient==code than to do

CodePudding user response:

refer to the second floor Li Mu general response:
Quote: refer to 1st floor TorresFans response:
this problem is worth 20 points, more may be someone to




Not points, the first topic is the screenshot, followed by work, finally also does not have the code, call us to do, but this is not the first time he send the homework bosses to help capture the==every time is o...
I think watching code than to convenient to solve the problem.==

Well, help you to finish your homework, you do what? The university let others help you?

CodePudding user response:

#include
Void InputData (int data [], [2], int * size)
{
Printf (" please enter the number of personnel number less than 500: \ n ");
The scanf (" % d ", size);

Printf (" please enter start and end time into % d \ n ", * the size).
for(int i=0; i<* the size; I++)
{
Printf (" please enter the first % d set of data, the data is less than 1000000 \ n ", I);
The scanf (" % d ", & amp; Data [I] [0]);
The scanf (" % d ", & amp; Data [I] [1]);
}
}
Void GetLong (int * doTime, spaceTime int * and an int data [] [2], int size)
{
Int tmp_start=data [0] [0], tmp_end=data [0] [1].
Int tmp_space=data [0] [0].
for(int i=0; i{
If (data [I] [0] & gt;=tmp_start & amp; & Data [I] [0] <=tmp_end)
{
Tmp_end=tmp_end & gt; Data [1] [I]? Tmp_end: data [I] [1];
}
The else {
Int interval=data [1] - [I] data [I] [0];
Int tmpInterval=tmp_end - tmp_start;
//no one milking time longest
If (tmp_space & lt; (data [I] [0] - tmp_end))
{
Tmp_space=data [I] [0] - tmp_end;
}
//at least one milking time longest
If (tmpInterval{
Tmp_start=data [I] [0];
Tmp_end=data [I] [1];
}
}
}
* doTime=tmp_end - tmp_start;
* spaceTime=tmp_space;
}
Void SortArray (int data [], [2], int size)
{
for(int i=0; i{
If (data [I] [0] & gt; Data [I + 1] [0])
{
Int TMP=data [I] [0];
Data [I] [0]=data [0] [I + 1];
Data [I + 1] [0]=TMP;

TMP=data [I] [1];
Data [I] [1]=data [I + 1] [1];
Data [I + 1] [1]=TMP;
}
}
}
Void main ()
{
Int PersonNum=0;
Int StartEnd [500] [2]={0};
Int doTime=0, spaceTime=0;
InputData (StartEnd, & amp; PersonNum);
SortArray (StartEnd PersonNum);
GetLong (& amp; DoTime, & amp; SpaceTime, StartEnd PersonNum);
Printf (" at least one of the longest nursing time longest unmanned milking time: % d % d \ n ", doTime, spaceTime);
getchar();
getchar();
}
  • Related