| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1285 人关注过本帖
标题:[原创]一个简单的java 程序
只看楼主 加入收藏
lingxiang
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-6-17
收藏
得分:0 
那个c组是用来放d 组的下标的,互动转换, 输出的时候用(例:如果输出排序后的第一个a(c(i)),c[i] 用来做重排序后的下标
2005-06-22 18:45
lingxiang
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-6-17
收藏
得分:0 
版主能不能告诉我一些关于applet的我现在刚刚开始学,什么也不会,,没有什么大致的思路,关于java的简洁而快速的学法谢谢
2005-06-22 18:47
tempnetbar
Rank: 2
等 级:新手上路
威 望:4
帖 子:582
专家分:4
注 册:2004-5-5
收藏
得分:0 
applet的话基本上用不到了,所以建议不要学,当然不能说完全不用。Java的话一般就是学好J2SE就行了,剩下的有了J2SE基础都比较好学。那个数组C我觉得没用啊,排序只用到b数组,写入文件也只用到b数组就行了

相信勤能补拙! 喜欢用好用的就永远学不到有用的。
2005-06-22 21:10
lingxiang
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-6-17
收藏
得分:0 
我用c组把这个程序写出来了一会给发上来
2005-06-24 11:21
lingxiang
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-6-17
收藏
得分:0 
import *;
public class Dong{
  public static void main(String[] args) throws IOException
   {
   int m=0;
  try{
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   BufferedWriter bw=new BufferedWriter(new FileWriter("d:\\a.txt"));
   String s;
   while(true){
      System.out.println("输入班级");
        s=br.readLine();
        if(s.length()==0) break;
        bw.write(s);
        bw.newLine();System.out.println("输入姓名");
         s=br.readLine();
         bw.write(s);
         bw.newLine();
      System.out.println("输入成绩");
         s=br.readLine();
         bw.write(s);
         bw.newLine();
      m=m+1;
      }
      br.close();
      bw.close();
   String a[]=new String[m];
  int d[]=new int[m];
   int b[]=new int[m];
   int c[]=new int[m];
BufferedReader bf=new BufferedReader(new FileReader("d:\\a.txt"));
   int j=0;
   while(true){
         String ss=bf.readLine();
         if(ss==null)
            break;
         int greade1=Integer.parseInt(ss);               
         d[j]=greade1;
         ss=bf.readLine();
         a[j]=ss;
         ss=bf.readLine();
         int greade=Integer.parseInt(ss);               
         b[j]=greade;
         j++;   
    }
     bf.close();
   BufferedWriter bw1=new BufferedWriter(new FileWriter("d:\\b.txt"));
   BufferedWriter br1=new BufferedWriter(new OutputStreamWriter(System.out));
    int k,t,f,n;
      for(int i=0;i<j-1;i++){
          c[i]=i;
        }
      for(int i=0;i<a.length-1;i++){
        k=i;
        for(n=i+1;n<a.length;n++){
          if (b[n]<b[k]){
           k=n;
           t=b[i];
           b[i]=b[k];
           b[k]=t;
           f=c[i];
           c[i]=c[k];
           c[k]=f;
             }
           }
         }
      for(int x=0;x<c.length;x++){
        bw1.write(String.valueOf(d[c[x]]+","+a[c[x]]+","+b[x]));
        br1.write(String.valueOf(d[c[x]]+","+a[c[x]]+","+b[x]));
        bw1.newLine();
        br1.newLine();
        }
        bw1.close();
        br1.close();
      }
  catch (FileNotFoundException fe)
    { System.out.println(fe.toString());}
  catch (IOException ie)
    { System.out.println(ie.toString());}
   }
}
源程序
2005-06-24 11:36
「浩浩峰
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2005-6-18
收藏
得分:0 
语法好多的都有错误```再就是,如果想这样做的话,可以用filedialog对话框来做``主要是文件的输入输出流

不要心急,慢慢的来~~
2005-06-24 20:32
tempnetbar
Rank: 2
等 级:新手上路
威 望:4
帖 子:582
专家分:4
注 册:2004-5-5
收藏
得分:0 
数组D呢?没有申明啊,你就在程序里直接用了

相信勤能补拙! 喜欢用好用的就永远学不到有用的。
2005-06-25 07:21
lingxiang
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-6-17
收藏
得分:0 
d数组申明了呀?在上面有的,
2005-07-01 14:51
lingxiang
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2005-6-17
收藏
得分:0 
对了版主,我现在刚刚接触JAVA ,你给提一下意见,我该从哪里入手呢?学的时间好学
2005-07-01 14:53
快速回复:[原创]一个简单的java 程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025222 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved