删除指定字符串
#include<stdio.h> #include<string.h> int main(){ char str[100],Del[100]; gets(str);/*输入字符串*/ gets(Del); delete_char(str,Del); return 0; } void delete_char(char str[],char Del[]){ int i,j,k; int str_len = strlen(str);/*计算字符串长度*/ int Del_len = strlen(Del); for(i = 0;i < str_len; i++){ for(j = 0;j < Del_len; j++){ if(Del[j] == str[i]){ for(k = i;k < str_len; k++){ str[k] = str[k + 1]; } str_len--; i--; } } } str[str_len] = '\0'; puts(str); }
#include<stdio.h>
int main(){
int rooster,hen,chicken;
for(rooster = 0;rooster <= 100;rooster++){
for(hen = 0;hen <= 100;hen++){
for(chicken = 0;chicken <= 100;chicken += 3){
if(rooster + hen + chicken == 100 && 5 * rooster + 3 * hen + chicken / 3 == 100){
printf("%d %d %d\n",rooster,hen,chicken);
}
}
}
}
return 0;
}