求大神看看为什么这段代码通不过华为OJ系统的测试

ziyou627 2014-12-11 03:53:23
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
System.out.print("输入:");
String str=scanner.nextLine();
while(str.length()>128)
{
System.out.print("输入:");
str=scanner.nextLine();
}
if(str.trim().isEmpty())
System.out.print("输出:"+0);
else {String[] strarr=str.split(" ");
int len=strarr.length;
System.out.print("输出:"+strarr[len-1].length());
}
}
}
...全文
197 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
scott_129 2014-12-11
  • 打赏
  • 举报
回复
你需要严格按照题目的要求来写程序,没让你换行,就不要换行,没让你加显示”输入:“这样的提示就不能写这样的提示。 再好好看看吧。
soton_dolphin 2014-12-11
  • 打赏
  • 举报
回复
如果是让你写算法,唯一的输入就是方法的参数,算法里面不应该用system.out.println(); 把你的题目放上来看看
wyc_ 2014-12-11
  • 打赏
  • 举报
回复
输入就输入吧,System.out.print("输入:");这是干嘛?
ningbohezhijun 2014-12-11
  • 打赏
  • 举报
回复
华为的oj让你输出这么多无用的话了吗?

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧