Auto commit
This commit is contained in:
		
							parent
							
								
									dae819bf03
								
							
						
					
					
						commit
						e229bbbb5d
					
				@ -21,7 +21,16 @@ void fun(int *w, int p, int n)
 | 
			
		||||
{
 | 
			
		||||
    int temp[p + 1];
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    
 | 
			
		||||
    int i,k=0;
 | 
			
		||||
	for(i=0;i<p+1;i++){
 | 
			
		||||
		temp[i] = w[i];
 | 
			
		||||
	}
 | 
			
		||||
	for(;i<n;i++){
 | 
			
		||||
		w[k++]=w[i];
 | 
			
		||||
	}
 | 
			
		||||
	for(i=0;k<n;k++){
 | 
			
		||||
		w[k]=temp[i++];
 | 
			
		||||
	}
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
}
 | 
			
		||||
int main()
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,12 @@ char *fun(char input[])
 | 
			
		||||
    }
 | 
			
		||||
    int outputIndex = 0;
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    int i;
 | 
			
		||||
    for(i=0;i<len;i++){
 | 
			
		||||
    	while(input[i]=='['){
 | 
			
		||||
    		
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
    return output;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -16,7 +16,13 @@ int totalBottles(int money)
 | 
			
		||||
    int boughtBottles = money;
 | 
			
		||||
    int newBottles;
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    
 | 
			
		||||
	totalBottlesDrank= money;
 | 
			
		||||
	while(boughtBottles > 1){
 | 
			
		||||
		boughtBottles-=2;
 | 
			
		||||
		boughtBottles++;
 | 
			
		||||
		totalBottlesDrank++;
 | 
			
		||||
	}
 | 
			
		||||
	return totalBottlesDrank;
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
}
 | 
			
		||||
int main()
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,23 @@ void fun(int *a, int n)
 | 
			
		||||
    int second_max_index = 0;
 | 
			
		||||
    int i;
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    for(i=1;i<n;i++){
 | 
			
		||||
    	if(a[i]>a[max_index]){
 | 
			
		||||
	    	max_index = i;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	i=a[0];
 | 
			
		||||
	a[0]=a[max_index];
 | 
			
		||||
	a[max_index]=i;
 | 
			
		||||
	second_max_index = 1;
 | 
			
		||||
	for(i=1;i<n;i++){
 | 
			
		||||
		if(a[i]>a[second_max_index]){
 | 
			
		||||
			second_max_index = i; 
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	i=a[1];
 | 
			
		||||
	a[1]=a[second_max_index];
 | 
			
		||||
	a[second_max_index]=i;
 | 
			
		||||
	
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -39,7 +39,35 @@ int computeSymmetricDifference(int A[], int sizeA, int B[], int sizeB, int C[])
 | 
			
		||||
{
 | 
			
		||||
    int i = 0, j = 0, k = 0;
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    
 | 
			
		||||
	while(i<sizeA){
 | 
			
		||||
		j=0;
 | 
			
		||||
		while(j<sizeB){
 | 
			
		||||
			if(A[i]==B[j]){
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			j++;
 | 
			
		||||
		}
 | 
			
		||||
		if(j==sizeB){
 | 
			
		||||
			C[k++]=A[i];
 | 
			
		||||
		}
 | 
			
		||||
		i++;
 | 
			
		||||
	}
 | 
			
		||||
	j=i=0;
 | 
			
		||||
	while(j<sizeB){
 | 
			
		||||
		i=0;
 | 
			
		||||
		while(i<sizeA){
 | 
			
		||||
			if(A[i]==B[j]){
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			i++; 
 | 
			
		||||
		}
 | 
			
		||||
		if(i==sizeA){
 | 
			
		||||
			C[k++]=B[j];
 | 
			
		||||
		}
 | 
			
		||||
		j++;
 | 
			
		||||
	}
 | 
			
		||||
	bubbleSort(C,k);
 | 
			
		||||
	return k;
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
}
 | 
			
		||||
int main()
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,17 @@ Z ת
 | 
			
		||||
void fun(char *str)
 | 
			
		||||
{
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    
 | 
			
		||||
	char *p;
 | 
			
		||||
	p=str;
 | 
			
		||||
	while(*p != '\0'){
 | 
			
		||||
		if(*p>='a'&&*p<='z'){
 | 
			
		||||
			*p=((*p+1)<'z'?(*p+1):'a');
 | 
			
		||||
		}
 | 
			
		||||
		if(*p>='A'&&*p<='Z'){
 | 
			
		||||
			*p=((*p+1)<'Z'?(*p+1):'A');
 | 
			
		||||
		}
 | 
			
		||||
		p++;
 | 
			
		||||
	}
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
}
 | 
			
		||||
int main()
 | 
			
		||||
 | 
			
		||||
@ -12,7 +12,15 @@
 | 
			
		||||
int mySqrt(int x)
 | 
			
		||||
{
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    
 | 
			
		||||
    int i;
 | 
			
		||||
	for(i=1;;i++){
 | 
			
		||||
		if(i*i==x){
 | 
			
		||||
			return i;
 | 
			
		||||
		}
 | 
			
		||||
		if(i*i>x){
 | 
			
		||||
			return i-1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
}
 | 
			
		||||
int main()
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,15 @@ Program-End ֮
 | 
			
		||||
bool hasDuplicates(int arr[], int size)
 | 
			
		||||
{
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    
 | 
			
		||||
    int i,j;
 | 
			
		||||
	for(i=0;i<size-1;i++){
 | 
			
		||||
		for(j=i+1;j<size;j++){
 | 
			
		||||
			if(arr[i]==arr[j]){
 | 
			
		||||
				return 1;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return 0;
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
}
 | 
			
		||||
int main()
 | 
			
		||||
 | 
			
		||||
@ -41,14 +41,20 @@ Program-End ֮
 | 
			
		||||
#define TANK_CAPACITY 100                     // 电池总容量(单位:度)
 | 
			
		||||
#define LOW_FUEL_LIMIT (0.10 * TANK_CAPACITY) // 低电量阈值(10%)
 | 
			
		||||
#define AVG_CONSUMPTION_PER_100KM 10          // 平均电耗(单位:度/百公里)
 | 
			
		||||
#define FUEL_CONSUMPTION_PER_KM (AVG_CONSUMPTION_PER_100KM /
 | 
			
		||||
100.0) // 每公里电耗(单位:度/公里)
 | 
			
		||||
#define FUEL_CONSUMPTION_PER_KM (AVG_CONSUMPTION_PER_100KM / 100.0) // 每公里电耗(单位:度/公里)
 | 
			
		||||
int checkRefuelStops(int trips[], int count, int results[])
 | 
			
		||||
{
 | 
			
		||||
    int refuel_count = 0;
 | 
			
		||||
    double current_fuel = TANK_CAPACITY;
 | 
			
		||||
    /**********Program**********/
 | 
			
		||||
    
 | 
			
		||||
	int i;
 | 
			
		||||
	for(i=0;i<count;i++){
 | 
			
		||||
    	current_fuel = current_fuel-FUEL_CONSUMPTION_PER_KM*trips[i];
 | 
			
		||||
		if(current_fuel<=LOW_FUEL_LIMIT){
 | 
			
		||||
    		results[refuel_count++]=i+1;
 | 
			
		||||
    		current_fuel=TANK_CAPACITY - FUEL_CONSUMPTION_PER_KM*trips[i];
 | 
			
		||||
		}
 | 
			
		||||
	} 
 | 
			
		||||
    /********** End **********/
 | 
			
		||||
    return refuel_count;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user