c语言subscripted_c语言。数组的问题。急!
題目是這樣的:Useasingle-subscriptedarraytosolvethefollowingproblem.Readin20numbers,eachofwhichisbetween10and100,inclusive.Aseachnumberisread,printitonlyifitisnotaduplica...
題目是這樣的:Use a single-subscripted array to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Prepare for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.
我的問題是:怎樣檢驗輸入的數(shù)與以前輸入過的數(shù)是否相同呢?用什么方法呢?
int main()
{
int nums[20];
int i;
printf("If the first number you type is not a right number, it will output the number 0.\n");
for(i=0;i<20;i++)
{ int counter=1;
printf("Please type in a number within the interval [10,100]:\n");
scanf("%d",&nums[i]);
rule=nums[0];
if(i==0)
printf("The number you have just typed is %d\n",nums[i]<100&&nums[i]>10?nums[i]:0);
else if(nums[i]<100&&nums[i]>10&&i!=0)
printf("The number you have just typed is %d\n",nums[i]);
else if (nums[i]>=100||nums[i]<=10)
printf(" The number you huve just typed is a wrong number.\n");
}
return 0;
}
展開
總結(jié)
以上是生活随笔為你收集整理的c语言subscripted_c语言。数组的问题。急!的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 万豪钛金卡和白金卡的区别 万豪钛金卡和白
- 下一篇: 公积金有1000能取多少 公积金里面有1