回复 3楼 TonyDeng
程序大概写出来了,只是有些地方觉得不知道怎么改了,你帮我看看嘛,
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char str[]="It goes without any afestion that afreer plays a key ddule in our due. In the very first place, career can give us an";
void Check()
{
char Check;
printf("would you want check the virtus:(y/n)?\n");
Check=getchar();
if(Check=='y')
{
printf("If you want to see the result about this,please press the key(y/n)\n");
}
else
printf("That's a pity!\n");//这里怎么能够跳过主函数的Count()
}
void Count()
{
int i,j,n=0,af=0,du=0;
int len = strlen(str);
for(i=0;i<len;i++)
{
if(str[i]=='a'&&str[i+1]=='f')
af++;
if(str[i]=='d'&&str[i+1]=='u')
du++;
}
printf("af的个数是:%d du的个数是:%d\n",af,du);
}
void String_Cut(char str[])这个函数怎样能够选择另外一个字符串?
{
int i, j=0;
char str2[256],c;
int len = strlen(str);
printf("please input a char that you want to delete:\n");
c=getchar();
if(c=='y')
{
for(i=0; i<len; i++)
{
if (str[i]=='a'&&str[i+1]=='f')
{
str2[j] = str[i+2];
j++;
i=i+2;
}
else
{
str2[j]=str[i];
j++;
}
}
str2[j] = '\0';
puts(str2);
}
else
{
str2[len]='\0';
puts(str);
}
}
void main()
{
puts(str);
Check();
Count();
String_Cut(str);
}