程序填空
下面的程序中,函数delstr的功能是:
将字符串str中所有出现的子串str1全部删除。如本程序的输出为:
“I am a, You are a,
He is a too.”
Include “string.h”
Include “iostream”
Using namespace std;
Char *delstr(char *str,char *str1)
{
char *p,*p1,*q1; int i;
if(*str==’\0’||*str1==’\0’)
return str;
p=str;
while (*p!=’\0’)
{
p1=p;
q1=str1;
while(*p==*q1&&*q1!=’\0’)
if (p!=&& *q1==’\0’)
{
For(i=0; *p!=’\0’; i++; p1++)
=*p1;
=’\0’;
}
P++;
{
Char *p, *p1, *q1; int I;
If(*str==’\0’||*str1==’\0’)
Return str;
P=str;
While(*p!=”\0”)
{
P1=p;
Q1=str1;
While(*p!=”\0”)
{
P1=p;
Q1=str1;
While(*p1==*q1&&*q1!=’\0’) ;
If(p!=p1&&q1==’\0’)
{
For(i=0;*p1!=’\0’;i++,p1++)
=*p1;
=’\0’;
}
P++;
}
Return ;
}
void main()
{
char line[80]=”I am a student, You are a student. He is a student too.”
Cout<<delstr(line,”student”)<<end1
我就顺便出一个我们最近大作业要做的一个C的题目吧
要求实现一个高精度无符号整数乘法的函数,函数原型为void Multiply(WORD *R, WORD* A, WORD *B, unsigned int N),其中R为结果,A与B为两个乘数,N为乘数的长度(单位为WORD)。WORD为你们定义的存储长整数每一部分的类型,由你们自己定义。大作业的具体要求如下:
N可能会非常大,你们在设计该函数时候不能假设N的大小。
可以用小学生乘法或分治法递归做。
谁会也顺便传上来一下。