Auto commit
This commit is contained in:
+11
-6
@@ -39,11 +39,16 @@ int calculateDeliveryTimes(int weights[], int size) {
|
||||
int deliveryTimes = 1;
|
||||
|
||||
/**********Program**********/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int i;
|
||||
for(i=0;i<size;i++){
|
||||
if(weights[i] <= 50){
|
||||
if(currentWeight + weights[i] > 50){
|
||||
currentWeight=0;
|
||||
deliveryTimes++;
|
||||
}
|
||||
currentWeight += weights[i];
|
||||
}
|
||||
}
|
||||
/********** End **********/
|
||||
return deliveryTimes;
|
||||
}
|
||||
@@ -67,4 +72,4 @@ int main() {
|
||||
printf("需要%d次才能将所有包裹配送完毕。\n", times);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user