ä¸ãç®æ³æè¿°
é个æ¯è¾å符串sourceä¸çå符ï¼è¥å½åiä½ç½®çå符çäºå¾ å é¤å符chï¼åi+1..len-1ä¹é´çå串æ´ä½å移ï¼å¦æ¤åå¤ï¼ç´å°ææå¾ å é¤å符é½æ¾å°å¹¶è¢«å é¤ä¸ºæ¢ã
äºãæä½è¿ç¨
ä¸ãåèç¨åº
#include <stdio.h>åãè¿è¡æµè¯
请è¾å ¥ä¸ä¸ªå符串ï¼How are you?挑出其中需要的字符存回来就行了
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
void delChar(char *str,char m)
{
int len=strlen(str);
int i,j=0;
char *p=(char *)malloc(len*sizeof(char));
memset(p,0,len);
for(i=0;i<len;i++)
{
if(*(str+i)!=m)
*(p+j++)=*(str+i);
}
memset(str,0,len);
strncpy(str,p,strlen(p));
free(p);
}
int main()
{
char str[100]={0};
char del;
scanf("%s %c",str,&del);
delChar(str,del);
puts(str);
}
结果:
追问好厉害啊!
追答一般般,呵呵
追问请编写函数countvalue(),它的功能是:求n以内(不包括n)同时能被3和7整数的所有自然数之和的平方根s,并作为函数值返回,最后结果s输出到文件out.dat中。
例如若n为1000时,函数值应为:s=153.909064。这个怎么做?