【发布时间】:2016-07-27 11:19:24
【问题描述】:
编写一个程序,它接受两个字符串,并在没有双精度的情况下显示 出现在任一字符串中的字符。
将按照字符在命令行中出现的顺序显示,并且
后面是\n。
简而言之,我想做这样的事情:
first string: "zpadinton"
second string: "paqefwtdjetyiytjneytjoeyjnejeyj"
输出将是:
output: "zpadintoqefwjy"
其他例子:
string1: "rien"
string2: "cette phrase ne cache rien"
output: "rienct phas"
string1: "ddf6vewg64f"
string2: "gtwthgdwthdwfteewhrtag6h4ffdhsd"
output: "df6vewg4thras"
我正在尝试做类似的事情:
char et(char *str, char *str2)
{
int i;
int current;
int check;
char tmp[strlen(*str) + strlen(*str2)];
i = 0;
current = 0;
check = 0;
while(*str)
{
check = 0;
while (check != current){
if (tmp[check] == *str)
return (0);
check++;
}
if (check == current)
{
printf("%c", *str);
tmp[current] = *str;
++check;
}
str++;
}
while(*str2)
{
check = 0;
while (check != current){
if (tmp[check] == *str2)
return (0);
check++;
}
if (check == current)
{
printf("%c", *str2);
tmp[current] = *str2;
++check;
}
str2++;
}
return (0);
}
但这不起作用。 我猫是怎么做到的?
P.S:我想在不使用函数 strcmp strcpy 或 boolean type of date 或类似的东西的情况下做到这一点。
【问题讨论】:
-
你的意思是
second string: "Hello"? -
问题是什么?
-
@Dumitru Srelet,....“你好”?......不是“你好”?
-
那么 hello world 示例将输出“Wrd”而不是“World”。重新表述问题并严格定义“差异”。
-
这是42所学校的科目。