【发布时间】:2019-05-21 06:14:59
【问题描述】:
如何从 key(b) 中获取重复的数字我的程序是这样的,用户输入 166456 并且 key = 6 那么输出必须像 6 在数组中重复 3 次请告诉我这是否可以没有数组完成
我什至收到错误 int cannot be to int[]
int []a,i,j,count=0,b=0,n;
Scanner sc=new Scanner(System.in);
n=sc.nextInt(System.in);
int []a=new int[n];
for(i=0;i<n;++i)
{
a[i]=sc.nextInt();
}
System.out.println("Which nuber would you like to find:");
b=sc.nextInt();
for(j=0;j<n;++j)
{
if(a[i]==b)
{
++count;
}
else
{
System.out.println("Not found");
}
}
System.out.println("No of time "+b+" is repeated "+count);
【问题讨论】: