Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 哪位大哥来帮帮忙:我写的java程序错在哪?
lvli_727





发贴: 6
积分: 0
于 2005-12-23 08:18 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

import java.awt.Point;
import java.io.*;
import java.util.*;

class Kmeans {

public static void main ( String [] arguments ) {

String str,s1;
int n,k; //10
BufferedReader br = new BufferedReader( new InputStreamReader(System.in));

System.out.println("how many clusters do you want?");
str = br.readLine();
k = Integer.parseInt(str);
System.out.println("how many vectors do you have?");
s1 = br.readLine();
n = Integer.parseInt(s1);
Acluster[] aclu = new Acluster[k];
Avector[] vec = new Avector[n]; //20

Kmeans obj = new Kmeans();
vec = obj.input (vec , n);
System.out.println ("vectors:");
for(i=0 ; i<n; i++){
System.out.println(vec[i].pt);
}

Avector[] input ( Avector[] aa,int nn) {
String str1,str2;
BufferedReader br1 = new BufferedReader( new InputStreamReader (System.in));
//30
System.out.println("please enter vectors:");
for(int i=0 ; i<nn ; i++){
System.out.println("第" + i +"个矢量的x分量:" );
str1 = br1.readLine();
try {
aa[i].pt.x = Integer.parseInt (str1);
}
catch(NumberFormatException exc){ //40
System.out.println("Invalid format");
aa[i].pt.x=0;
}

System.out.println("第" + i +"个矢量的y分量:");
str2 = br1.readLine();
try {
aa[i].pt.y = Integer.parseInt (str2);
}
catch(NumberFormatException exc){ //50
System.out.println("Invalid format");
aa[i].pt.y=0;
}
}
return aa;
}
}

class Acluster{
Point center;
int member;
int index; //60

public Acluster (Point center, int member, int index){
this.center = center;
this.member = member;
this.index =index;
}

public Point getcenter (){
return center;
} //70

public int getmember (){
return member;
}

public int getindex (){
return index;
}
}
//80
class Avector{
Point pt;
int sign;

public Avector (Point pt ,int sign) {
this.pt = pt;
this.sign = sign;
}

public int getsign (){ //90
return sign;
}

public Point getpt (){
return pt;
}
}
}

编译时提示我没法读???


why edited on 2005-12-23 08:30


话题树型展开
人气 标题 作者 字数 发贴时间
4286 哪位大哥来帮帮忙:我写的java程序错在哪? lvli_727 2920 2005-12-23 08:18
3159 Re:哪位大哥来帮帮忙:我写的java程序错在哪? why 401 2005-12-23 08:31
3313 Re:哪位大哥来帮帮忙:我写的java程序错在哪? lvli_727 4 2005-12-23 17:01

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923