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.

我的问题是:怎样检验输入的数与以前输入过的数是否相同呢?用什么方法呢?

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;

}

展开

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值