我寫一個簡單的程序,其中用戶在整數進入幾個值我已經寫到目前爲止array.The代碼是這樣在一個整數數組以獨特的輸入
#include<stdio.h>
#include<stdlib.h>
void main(){
int array[10],x,y;
for(x=0;x<10;x++)
{
scanf("%d",&array[x]);
//if the entered value is same as any of
//the previously entered values
//prompt the user to enter again till
//he enters a unique value.
} }
我想在整數陣列是唯一的,如果用戶輸入先前輸入的值,則應提示他再次輸入。 我怎麼可能做到這一點? 也許使用goto語句?但我猜想這是非常令人沮喪的。 使用while循環?但我需要循環先前輸入的值來檢查重複項,我無法對其進行編碼。 任何幫助表示讚賞
「我需要通過以前輸入的值循環,重複檢查,我不能夠實現代碼」 - 爲什麼不呢? –