試題說明 :
===========================================
給定程序MODI1.C中函數(shù) fun 的功能是:將在字符串s中出現(xiàn)、
而未在字符串t中出現(xiàn)的字符形成一個(gè)新的字符串放在u中,u中字
符按原字符串中字符順序排列,不去掉重復(fù)字符。
例如:當(dāng)s = "AABCDE",t = "BDFG"時(shí),
u中的字符串為"AACE"。
請(qǐng)改正函數(shù)fun中的錯(cuò)誤,使它能得出正確的結(jié)果。注意:不
要改動(dòng)main函數(shù),不得增行或刪行,也不得更改程序的結(jié)構(gòu)!
===========================================
程序 :
===========================================
#include
#include
#include
/************found************/
void fun (char *s, char *t, char u)
{ int i, j, sl, tl;
sl = slen(s); tl = slen(t);
for (i=0; i { for (j=0; j if (s[i] == t[j]) break;
/************found************/
if (j>tl)
*u = s[i];
}
*u = '\0';
}
main()
{ char s[100], t[100], u[100];
clrscr();
printf("\nPlease enter sing s:"); scanf("%s", s);
printf("\nPlease enter sing t:"); scanf("%s", t);
fun(s, t, u);
printf("the result is: %s\n", u);
}
===========================================
所需數(shù)據(jù) :
===========================================
#2
@1 001010
void fun (char *s,char *t, char *u)
void fun (char *s,char *t, char u[])
void fun (char *s,char *t, char u[100])
fun (char *s,char *t, char *u)
fun (char *s,char *t, char u[])
fun (char *s,char *t, char u[100])
fun (char s[],char t[], char u[])
fun (char s[100],char t[100], char u[100])
void fun (char s[],char t[], char u[])
void fun (char s[100],char t[100], char u[100])
@2 001006
if(j>=tl)
if(tl<=j)
if(!(jif(!(tl>j))
if(j==tl)
if(tl==j)
===========================================
給定程序MODI1.C中函數(shù) fun 的功能是:將在字符串s中出現(xiàn)、
而未在字符串t中出現(xiàn)的字符形成一個(gè)新的字符串放在u中,u中字
符按原字符串中字符順序排列,不去掉重復(fù)字符。
例如:當(dāng)s = "AABCDE",t = "BDFG"時(shí),
u中的字符串為"AACE"。
請(qǐng)改正函數(shù)fun中的錯(cuò)誤,使它能得出正確的結(jié)果。注意:不
要改動(dòng)main函數(shù),不得增行或刪行,也不得更改程序的結(jié)構(gòu)!
===========================================
程序 :
===========================================
#include
#include
#include
/************found************/
void fun (char *s, char *t, char u)
{ int i, j, sl, tl;
sl = slen(s); tl = slen(t);
for (i=0; i { for (j=0; j if (s[i] == t[j]) break;
/************found************/
if (j>tl)
*u = s[i];
}
*u = '\0';
}
main()
{ char s[100], t[100], u[100];
clrscr();
printf("\nPlease enter sing s:"); scanf("%s", s);
printf("\nPlease enter sing t:"); scanf("%s", t);
fun(s, t, u);
printf("the result is: %s\n", u);
}
===========================================
所需數(shù)據(jù) :
===========================================
#2
@1 001010
void fun (char *s,char *t, char *u)
void fun (char *s,char *t, char u[])
void fun (char *s,char *t, char u[100])
fun (char *s,char *t, char *u)
fun (char *s,char *t, char u[])
fun (char *s,char *t, char u[100])
fun (char s[],char t[], char u[])
fun (char s[100],char t[100], char u[100])
void fun (char s[],char t[], char u[])
void fun (char s[100],char t[100], char u[100])
@2 001006
if(j>=tl)
if(tl<=j)
if(!(jif(!(tl>j))
if(j==tl)
if(tl==j)