Duplicate Elimination with array) Use a one-dimensional array to solve the following
problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is
read, validate it and store it in the array only if it isn’t a duplicate of a number already read. After
reading all the values, display only the unique values that the user entered. Provide for the “worst
case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.
void Dea::Input()
{
cout<<"Enter any number between 10 and 100, 4 times \n";
do{
cin>> input;//user input
//check input the range
if (input>9 && input <101)
{
//a loop for check, I don't know how to do in here
// I want to use loop check without include any library
a[count]=input;
}
else // not right to store wrong value
a[count]=!input;
++count;
} while(count<4);
}
}
void Dea::display()
{
for(int count=0;count<4;count++)
cout<<a[count]<<" \n";
}
求大神教下 檢查重復的那部分 讓 不重復的進入ARRAY 然后 在DISPLAY 只有不重復的數字
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/102968.html
標籤:基礎類
下一篇:Qt osg瀏覽器插件中未嵌入模型的Qt編輯框無法輸入漢字和小寫字母,嵌入模型的編輯框什么都輸入不了,該怎么解決?
