您现在的位置: 中国男护士网 >> 考试频道 >> 计算机等级 >> 二级辅导 >> C语言 >> 辅导 >> 正文    
  二级C程序设计(一) 【注册男护士专用博客】          

二级C程序设计(一)

www.nanhushi.com     佚名   不详 

试题说明 :
===========================================
给定程序MODI1.C中函数 fun 的功能是: 将仅在字符串s中出
现而不在字符串t中出现的字符,和仅在字符串t中出现而不在字符
串s中出现的字符, 构成一个新字符串放在u中,u中的字符按原字
符串中字符顺序排列,不去掉重复字符。
例如:当s="AABCDE",t="BDFGG"时,
u中的字符串为:"AACEFGG"。
请改正函数fun中的错误,使它能得出正确的结果。注意:不要
改动main函数,不得增行或删行,也不得更改程序的结构!
===========================================
程序 :
===========================================
#include
#include
#include

void fun (char *s, char *t, char *u)
{ int i, j, sl, tl;
sl = strlen(s); tl = strlen(t);
for (i=0; i { for (j=0; j if (s[i] == t[j]) break;
/************found************/
if (j *u++ = s[i];
}
for (i=0; i { for (j=0; j if (t[i] == s[j]) break;
/************found************/
if (j *u++ = t[i];
}
*u = '\0';
}

main()
{ char s[100], t[100], u[100];
clrscr();
printf("\nPlease enter string s:"); scanf("%s", s);
printf("\nPlease enter string t:"); scanf("%s", t);
fun(s, t, u);
printf("The result is: %s\n", u);
}
===========================================
所需数据 :
===========================================
#2
@1 001006
if(j=tl)
if(!(jif(tlif(!(tlj))
if(j==tl)
if(tl==j)
@2 001006
if(j=sl)
if(!(jif(slif(!(slj))
if(sl==j)
if(j==sl)

 

文章录入:杜斌    责任编辑:杜斌 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
     

    联 系 信 息
    QQ:88236621
    电话:15853773350
    E-Mail:malenurse@163.com
    免费发布招聘信息
    做中国最专业男护士门户网站
    最 新 热 门
    最 新 推 荐
    相 关 文 章
    没有相关文章
    专 题 栏 目