栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

排除一样的元素在c语言中

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

排除一样的元素在c语言中

int main(){
int a[11];
int b[11];
int i;
int j;
printf("input the a[]:n");
for(i=0;i<11;i++){
scanf("%d",&a[i]);
printf("");
}

printf("input the b[]:n");
for(i=0;i<11;i++){
scanf("%d",&b[i]);
printf("");
}
int common=1000;

for(i=0;i<11;i++){
    for(j=0;j<11;j++){
 if(a[i]==b[j]){

     a[i]=common;
 }
 if(a[j]==b[i]){
     b[i]=common;
 }
    }
}
int record=0;
    //sum the zero number
 //remove the unnecessary zero
for(j=0;j<11;j++){
    if(a[j]!=common){
 record++;
    }

}
int share[record];
int test=0;
for(j=0;j<11;j++){
    if(a[j]!=common){
     share[test]=a[j];
     test++;
    }

}
//prevent the same number exist in the share
int recordsec=0;//record the repeat number
for(i=0;i

}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/233720.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号