没有得到所需的输出 [英] not getting the required output
本文介绍了没有得到所需的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
展开 | 选择 | Wrap | 行号
推荐答案
#include< iostream.h> ;
#include< conio.h>
void main()
{int a [10],b [10],i, j,k = 0,fg = 0;
for(i = 0; i< 5; i ++)
{cout<<"" enter no。 ;
cin>> a [i];}
for(i = 0; i< 5; i ++)
{for( j = 0; j <5; j ++)
{if(a [i] == a [j]&& i!= j)
{
fg = 1;
break;}}
if(fg == 0)
{b [k ] = A [1 ];
k ++;}}
for(i = 0; i< k; i ++)
cout<< b [i] ;
getch();}
这是从数组中删除重复值的程序。
如果我的输入是2,2,3,4,5
那么我应该得到输出3,4,5
但我是获得垃圾价值
但如果我输入我的输入1,2,3,3,4
然后我得到输出1,2,4这是对了
为什么我在第一种情况下没有得到输出。如果程序错误,请告诉我正确的程序
#include<iostream.h>
#include<conio.h>
void main()
{int a[10],b[10],i,j,k=0,fg=0;
for(i=0;i<5;i++)
{cout<<"enter no.";
cin>>a[i];}
for(i=0;i<5;i++)
{for(j=0;j<5;j++)
{if(a[i]==a[j]&& i!=j)
{
fg=1;
break;}}
if(fg==0)
{b[k]=a[i];
k++;}}
for(i=0;i<k;i++)
cout<<b[i];
getch();}
this is the program to remove duplicate values from an array.
if my input is 2,2,3,4,5
then i should get output 3,4,5
but i am getting garbage value
but if i put my input 1,2,3,3,4
then i get the output 1,2,4 which is right
why i am not getting the output in first case.please if the program is wrong then let me know the right program
我看到的第一件事是一堆meesy代码。请缩进并使用代码标签:
The first thing I saw is a pile of meesy code. Please indent and use code tags:
展开 | 选择 | Wrap | 行号
第一件事我锯是一堆meesy代码。请缩进并使用代码标签:
The first thing I saw is a pile of meesy code. Please indent and use code tags:
展开 | 选择 | Wrap | 行号
hpbrothers-
你' Mod已经被要求使用代码标签,现在你已经被专家用了。我正在发出正式警告 - 请阅读并遵循发布指南。如果你想发布,你必须遵守规则。
hpbrothers-
You''ve already been asked by a Mod to use code tags, and now yo uhave by an Expert. I''m making it an official warning - read and follow the Posting Guidelines. If you want to post, you have to play by the rules.
这篇关于没有得到所需的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文