C语言程序设计三题

# include & ltstdio.h & gt

作废?cal(int?n1,int?n2,char?f);

int?主()

{

int?n1,N2;

夏尔?f;

Printf("分别输入两个小于100的整数和一个运算符号:\ n ");

scanf("%d%d ",& ampn 1;N2);

getchar();

scanf("%c ",& ampf);

cal(n1,n2,f);

回归?0;

}

作废?cal(int?n1,int?n2,char?f)

{

int?an = 0;

开关(f)

{

案子?+':an = n 1+N2;打破;

案子?-':an = n 1-N2;打破;

案子?* ':an = n 1 * N2;打破;

案子?/':an = n 1/N2;打破;

案子?“%”:an = n 1% N2;打破;

}

printf("%d%c%d=%d\n ",n1,f,n2,an);

} #包含& ltstdio.h & gt

# include & ltstring.h & gt

作废?计数(char?*str1,char?* str 2);

int?主()

{

夏尔?str1[100]={0},str 2[8]= { 0 };

gets(str 1);

scanf("%s ",str 2);

count(str1,str 2);

回归?0;

}

作废?计数(char?*str1,char?*str2)

{

int?cnt=0,len1=strlen(str1),len2=strlen(str2),I,j,flag = 0;

for(i=0,j = 0;我& ltlen 1;i++,j++)

{

if(j==len2)

j =-1;

if(str1[i]!='?'?& amp& amp?旗帜)

继续;

if(str1[i]== '?'?& amp& amp?旗帜)

{

flag = 0;

j =-1;

继续;

}

if(str1[i]!='?'?& amp& amp?str2[j]!=str1[i])

{

flag = 1;

继续;

}

if((str1[i]== '?'?||?i==len1-1)?& amp& amp?!旗帜)

{

cnt++;

j =-1;

}

}

printf("%s?%d\n ",str2,CNT);

} #包含& ltstdio.h & gt

# include & ltstring.h & gt

作废?德勒(char?*str,char?c);

int?主()

{

夏尔?str[50]={0},c;

gets(str);

scanf("%c ",& ampc);

dele(str,c);

printf("%s\n ",str);

回归?0;

}

作废?德勒(char?*str,char?c)

{

int?len=strlen(str),I,j;

for(I = 0;我& ltleni++)

{

if(str[i]==c)

{

for(j = I;j & ltlen-1;j++)

{

str[j]= str[j+1];

}

str[len-1]= 0;

len-;

I-;

}

}

}