本文介绍了这个程序是为了找到给定输入的集合。即删除重复的元素。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include< stdio.h>

int count;

void create(float seta [],int n1,float tempa []);

int main()

{int i;

float * seta; float * setb; float * tempa; int n1,n2;

printf(输入集合1的元素:\ n);

printf(输入集合1中的元素数量:\\ n \\ n);

scanf(%d,& n1);

seta =(float *)malloc(n1 * sizeof(float));

for(i = 0; i< n1; i ++)

{

scanf(%f,seta + i);





}



printf(输入第2集的元素:\\ \\ n);

printf(输入第2组中的元素数量:\ n);

scanf(%d,& n2) ;

setb =(float *)malloc(n2 * sizeof(float));

for(i = 0; i< n2; i ++)

{

scanf(%f,setb + i);





}

create(seta,n1,tempa);

for(i = 0; i< count; i ++)

printf(%d ,*(tempa + i));





返回0;

}

void create(float a [20],int n1,float tempa [20])

{int count = 1,i,j,countverify; a [0] = tempa [0] ;

for(i = 0; i< n1; i ++)

{countverify = 0; for(j = 0; j< count; j ++)

if(tempa [j]!= a [i]){countverify ++;}

if(countverify ==数)

{

tempa [count] = a [i];计数++; }

}





} / *如果你想要,可以删除set b。声明要在后期阶段设置opwrations但首先让我知道错误是什么。我的编译器在扫描元素后停止了* /

#include<stdio.h>
int count;
void create(float seta[],int n1,float tempa[] );
int main()
{ int i;
float *seta; float *setb; float *tempa; int n1,n2;
printf("enter the elements of set 1:\n");
printf("enter the number of elements in set 1:\n");
scanf("%d",&n1);
seta=(float*)malloc(n1*sizeof(float));
for(i=0;i<n1;i++)
{
scanf("%f",seta+i);


}

printf("enter the elements of set 2:\n");
printf("enter the number of elements in set 2:\n");
scanf("%d",&n2);
setb=(float*)malloc(n2*sizeof(float));
for(i=0;i<n2;i++)
{
scanf("%f",setb+i);


}
create(seta,n1,tempa);
for(i=0;i<count;i++)
printf("%d",*(tempa+i));


return 0;
}
void create(float a[20],int n1,float tempa[20])
{int count=1,i,j,countverify;a[0]=tempa[0];
for(i=0;i<n1;i++)
{countverify=0; for(j=0;j<count;j++)
if(tempa[j]!=a[i]) {countverify++;}
if(countverify==count)
{
tempa[count]=a[i]; count++; }
}


} /*the set b can be removed if you want.it has been declared to do furthur set opwrations at later stages but first let me know what the error is .my compiler stopped after scanning the elements*/

推荐答案


这篇关于这个程序是为了找到给定输入的集合。即删除重复的元素。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 16:37