标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 70953 Accepted Submission(s):
30066
import java.util.*;
class Main{
public static void main(String args[])
{
Scanner cin=new Scanner(System.in);
while(cin.hasNext())
{
int n=cin.nextInt();
int m=cin.nextInt();
if(n==0&&m==0)
break;
int []a=new int [n+1];
int flag=0;
for(int i=0;i<n+1;i++)
{a[i]=cin.nextInt();
if(a[i]>m&&(flag==0))
{a[i+1]=a[i];
a[i]=m;
flag=1;
i++;}
}
for(int i=0;i<n;i++)
System.out.print(a[i]+" ");
System.out.println(a[n]);
}
}
}
这采用的是一个一个输入再进行比较。减少了循环的次数;
标签:
原文地址:http://www.cnblogs.com/1314wamm/p/5306111.html