A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© 洋葱头头   /  2016-1-31 15:37  /  18227 人查看  /  168 人回复  /   3 人收藏 转载请遵从CC协议 禁止商业使用本文

sun288225 发表于 2016-2-15 19:05
求分分,绝对没问题,我的路径写的E盘哈

你写错了把
回复 使用道具 举报

没有啊 我干脆手工直接打上来
  1. import java.io.BufferedReader;
  2. import java.io.BufferedWriter;
  3. import java.io.FileWriter;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.TreeSet;

  7. public class StirngDemo {

  8.         public static void main(String[] args) {
  9. //                想读多少都可以,键盘输入格式   名字,成绩,成绩,成绩(注意逗号小写)
  10.                 try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  11.                                 BufferedWriter bw = new BufferedWriter(new FileWriter("e:\\stu.txt"))) {
  12.                         String str = null;
  13. //                        建立规则从高分到低分
  14.                         TreeSet<Student> ts = new TreeSet<>((o1, o2) -> o2.sub() - o1.sub());
  15.                         while ((str = br.readLine()) != null) {
  16.                                 if (str.equals("over"))
  17.                                         break;
  18.                                 String[] s = str.split(",");
  19. //                                学生对象已new好存入集合中进行排序
  20.                                 Student xue = new Student(s[0], Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]));

  21.                                 ts.add(xue);
  22.                         }
  23.                         bw.write("姓名\t数学\t语文\t英语");
  24.                         bw.flush();
  25.                         bw.newLine();
  26. //                        执行打印
  27.                         for (Student student : ts) {
  28.                                 bw.write(student.getName()+"\t"+student.getShu()+"\t"+student.getYu()+"\t"+student.getYing());
  29.                                 bw.newLine();
  30.                                 bw.flush();
  31.                         }

  32.                 } catch (IOException e) {

  33.                         e.printStackTrace();
  34.                 }

  35.         }

  36. }
  37. //学生对象,把名字各科成绩总分变成属性,给予总分方法
  38. class Student {
  39.         private String name;
  40.         private int shu, yu, ying;

  41.         public String getName() {
  42.                 return name;
  43.         }

  44.         public Student(String name, int shu, int yu, int ying) {

  45.                 this.name = name;
  46.                 this.shu = shu;
  47.                 this.yu = yu;
  48.                 this.ying = ying;
  49.         }

  50.         public int getShu() {
  51.                 return shu;
  52.         }

  53.         public int getYu() {
  54.                 return yu;
  55.         }

  56.         public int getYing() {
  57.                 return ying;
  58.         }

  59.         public int sub() {
  60.                 return shu + ying + yu;
  61.         }

  62. }
复制代码
回复 使用道具 举报
输入小写 over程序 就结束 表示不再录入 大哥 给分吧
回复 使用道具 举报
sun288225 发表于 2016-2-15 19:20
没有啊 我干脆手工直接打上来

什么提示都没有  最后txt文件也不对
回复 使用道具 举报
明明知道怎么做,但也花了不少时间······急需练手,楼主再来10道~~

Test01.rar

1.4 KB, 下载次数: 88

答案

评分

参与人数 1技术分 +3 收起 理由
洋葱头头 + 3

查看全部评分

回复 使用道具 举报
求分求分!!严重缺技术分啊,花了半天写的

StudentInfo.rar

1.3 KB, 下载次数: 91

花了半天写的,求分啊!

评分

参与人数 1技术分 +3 收起 理由
洋葱头头 + 3

查看全部评分

回复 使用道具 举报
Kudychen 发表于 2016-2-16 14:49
求分求分!!严重缺技术分啊,花了半天写的

谢谢版主初级黑马不能聊天,能否加一下版主qq
回复 使用道具 举报
还不会生成txt文档
回复 使用道具 举报
太水了扎哈哈恩嘿嘿给!
回复 使用道具 举报
在不答可是要关闭了
回复 使用道具 举报
写完了,求给分,没有功劳也有苦劳啦~~~

student.rar

19.58 KB, 下载次数: 101

评分

参与人数 1技术分 +4 收起 理由
洋葱头头 + 4

查看全部评分

回复 使用道具 举报
答了答了求给分~~~~顶顶顶顶
回复 使用道具 举报
这么晚看到的,不知道还有没有分{:2_32:}

练习.rar

1.92 KB, 下载次数: 77

评分

参与人数 1技术分 +4 收起 理由
洋葱头头 + 4 赞一个!

查看全部评分

回复 使用道具 举报
昨天刚做的测试题,求技术分!

Test4.rar

1.58 KB, 下载次数: 85

评分

参与人数 1技术分 +4 收起 理由
洋葱头头 + 4 赞一个!

查看全部评分

回复 使用道具 举报
做好了,请查一下啦。!!!!

stu.rar

1.85 KB, 下载次数: 85

评分

参与人数 1技术分 +4 收起 理由
洋葱头头 + 4 赞一个!

查看全部评分

回复 使用道具 举报
求给分

test.rar

14.79 KB, 下载次数: 87

代码和运行结果

评分

参与人数 1技术分 +4 收起 理由
洋葱头头 + 4 赞一个!

查看全部评分

回复 使用道具 举报

吃饭 等会审核
回复 使用道具 举报

现在吃夜宵也太早了吧
回复 使用道具 举报
欢迎大神提出批评与指导

StudentTest.zip

2.07 KB, 下载次数: 83

评分

参与人数 1技术分 +4 收起 理由
洋葱头头 + 4

查看全部评分

回复 使用道具 举报
话说怎么没有往期题的链接了呢,差技术分呢
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马