Auto commit

This commit is contained in:
smallkun 2025-03-31 20:03:24 +08:00
parent 984e4b5848
commit dae819bf03
3 changed files with 30 additions and 3 deletions

View File

@ -33,7 +33,19 @@ void removeDuplicates(char *str)
if (len <= 1)
return;
/**********Program**********/
for(i=0;i<len-1;i++){
for(writeIdx=i+1;writeIdx<len;writeIdx++){
if(str[i] == str[writeIdx]){
seen[writeIdx] = 1;
}
}
}
writeIdx = 0;
for(i=0;i<len;i++){
if(seen[i]==0){
str[writeIdx++] = str[i];
}
}
/********** End **********/
str[writeIdx] = '\0';
}

View File

@ -22,7 +22,17 @@ void decimalToBinary(int decimal)
return;
}
/**********Program**********/
for(i=0;decimal>0;i++,decimal/=2){
binary[i] = decimal%2+48;
}
binary[i] = '\0';
i--;
for(;i>len;i--){
remainder = binary[len];
binary[len] = binary[i];
binary[i] = remainder;
len++;
}
/********** End **********/
printf("%s\n", binary);
}

View File

@ -17,7 +17,12 @@ int countPeaches(int lastDay)
int peaches = 1;
int day;
/**********Program**********/
day = lastDay;
while(day>1){
peaches = (peaches+1)*2;
day--;
}
return peaches;
/********** End **********/
}
int main()