我是新来编程,并被赋予一个任务,使一个数组放入其他具有以下条件的函数:目标数组中的变量将只重复一次,源和目标数组将相同尺寸。 我想出了一个功能:如何在取消重复变量时将一个数组更改为另一个数组?
int RemoveDup (int src[],int dst[])
//recive two array compare them and copy the src array to dst,and only the none reacuring
//numbers,the arrays must be from the same size
{
int size_src;
int size_dst;
int i,n=0;
size_src = sizeof(src)/sizeof(int);//determine the size of source array
size_dst = sizeof(dst)/sizeof(int);//determine the size of destination array
if (size_src = size_dst);//checks that the array are in the same size
{
for(i = 0;i < size_src;i++)//the loop for advancing the copying process
{
dst[i] = src[i];
}
while (i<size_dst)
{
dst[i] = dst[i++];
if (dst[i] = dst[i++])//relay on the fact that if the function will find a similar varibale, the tested varibale will be set to 0 and the other one will come out clean in the check
dst[i] = 0;//eliminating the varibale in that specific address
}
}
return dst [i];
,但它似乎并不工作,不知道它是怎么了。 任何帮助或线索将不胜感激。
要学的第一件事就是正确*缩进代码。否则,阅读左边排列的所有代码是非常困难的。 – 2010-12-19 21:32:44
@david:您会注意到编辑器中的小工具栏图标。标有'{}'的块将代码块呈现出来,这正是Anon对你所提出的问题。编辑页面的侧边栏中还有其他格式化选项。 – dmckee 2010-12-19 21:33:05
这是功课吗? – t0mm13b 2010-12-19 21:33:59