用JAVA写UVA的题目!帮我看看错在那儿?提交Wrong Answer

beanbaby2002 2003-06-04 09:40:59

我写的UVA题目
编译通过,本机执行可以,不知道那儿有错误,为什么提交说Wrong Answer


题目编号:10062

給你一列文字,請你找出各字元出現的次數。

Input

每筆測試資料一列。每列最大長度為1000。

Output

對每一列輸入,請輸出各字元的ASCII值及其出現的次數。請根據出現的次數由小到大輸出。如果有2個以上的字元有相同的次數,則ASCII值較大的先輸出。

測試資料間請空一列,參考Sample Output
Sample Input

AAABBC
122333

Sample Output

67 1
66 2
65 3

49 1
50 2
51 3


==================================
import java.io.*;
import java.util.*;
class Main{
static String ReadLn(int maxLg){
byte lin[]=new byte [maxLg];
int lg=0,car=-1;
try{
while(lg<maxLg){
car=System.in.read();
if((car<0)||(car=='\n')){
break;
}
lin [lg++]+=car;
}
}
catch (IOException e){
return (null);
}

if((car<0)&&(lg==0)){
return (null);
}
return (new String(lin, 0, lg));
}
public static void main(String[] args){
int intByte[]=new int[255];
boolean blnPrinted[]=new boolean[255];
for(int i=0;i<intByte.length;i++){
intByte[i]=0;
blnPrinted[i]=true;
}
for(;;){
int intTotal=0;
String strIn=new String(ReadLn(2000));
if(strIn.length()==1){
break;
}
byte b[]=strIn.getBytes();
for(int i=0;i<b.length-1;i++){
intByte[(new Byte(b[i])).intValue()]++;
blnPrinted[(new Byte(b[i])).intValue()]=false;
}
int intMax=1;
for(int i=0;i<intByte.length;i++){
if(intByte[i]!=0){
intMax=Math.max(intMax,intByte[i]);
intTotal++;
}
}
while(intTotal>0){
int intThis=0;
int intSmall=intMax;
for(int i=0;i<intByte.length;i++){
if(intByte[i]<=intSmall && blnPrinted[i]==false){
intThis=i;
intSmall=intByte[i];
}
}
System.out.println(intThis+" "+intByte[intThis]);
blnPrinted[intThis]=true;
intTotal--;
}
System.out.println();
for(int i=0;i<intByte.length;i++){
intByte[i]=0;
blnPrinted[i]=true;
}
}
}
}
...全文
149 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
beanbaby2002 2003-06-10
  • 打赏
  • 举报
回复
```
beanbaby2002 2003-06-05
  • 打赏
  • 举报
回复
顶顶顶,用JAVA提交过UVA题目的来看看啊!!
beanbaby2002 2003-06-04
  • 打赏
  • 举报
回复


不是
UVA的测试有.in .out文件

测试数据在.in文件里
输出的数据存在一个临时文档,然后和.out对比,如果想通,则判断正确的
mymoto 2003-06-04
  • 打赏
  • 举报
回复
對每一列輸入,請輸出各字元的ASCII值及其出現的次數

他可能是让你把所有列按上面结果输出吧
mymoto 2003-06-04
  • 打赏
  • 举报
回复
还没解决呢?呵呵,辛苦啊,帮你up一下
yangrouchuan 2003-06-04
  • 打赏
  • 举报
回复
什么是UVA?

62,616

社区成员

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

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