英文:
Can you read a .txt file without importing or using any Java standard library packages or components?
问题
以下是翻译好的内容:
我的作业要求之一是从*.txt文件中读取整数。然而,我们不允许导入或使用任何Java标准库包或组件。由于不能使用Scanner、File或其他有助于IO的工具,该如何实现呢?谢谢!
作业目标:完成作业后,学生应能够:
- 使用递归实现归并排序算法
- 使用递归实现快速排序算法
你将获得以下文本文件:
MyList.txt
- )你必须实现一个递归快速排序算法,该算法将从附加的
MyList.txt
文件中读取整数。你的算法必须按升序对列表(整数)进行排序。- 你必须实现一个递归归并排序算法,该算法将从附加的
MyList.txt
文件中读取整数。你的算法必须按升序对列表(整数)进行排序。- ScreenShots.doc或ScreenShots.pdf文件应包含两个程序的输出截图。
在你的.java文件中,不允许导入或使用任何Java标准库包或组件。
英文:
One of the requirements in my homework assignment is to read integers from a *.txt file. However, we are not allowed to import or use any Java standard library packages or components. How would this be accomplished since we can't use Scanner, File, or others that help with IO? Thanks!
> Homework Objective: After completing the homework, the student should
> be able to
> - Implement a merge sort algorithm using recursion
> - Implement a quick sort algorithm using recursion
>
> You are given the following text files:
> MyList.txt
> 1. ) You must implement a recursive Quicksort algorithm that will read integers from the attached MyList.txt
file. Your algorithm must sort
> the list (integers) in ascending order.
> 2. You must implement a recursive Mergesort algorithm that will read integers from the attached MyList.txt
file. Your algorithm must sort
> the list (integers) in ascending order.
> 3. ScreenShots.doc or ScreenShots.pdf This file should contain screenshots of your output for both the programs.
>
> You are not allowed to import or use any Java standard library
> packages or components in your .java files.
答案1
得分: 7
我认为在你的作业要求中有一个错误。
虽然可以在不使用任何标准Java I/O库包的情况下进行I/O,但这涉及编写C或C++代码方法来进行I/O,并通过JNI或JNA访问它们。我无法想象这是你的老师希望你在排序算法练习中做的...。
我预计你的老师实际上的意思是你的快速排序和归并排序的实现不应使用任何库包。
但说真的,如果你想要搞清楚作业的要求,唯一能做到的就是你的老师和助教。
英文:
I would say that there is a mistake in the requirements for your assignment.
While it is possible to do I/O without using any standard Java I/O library packages, it involves writing C or C++ code methods to do I/O and accessing them via JNI or JNA. I cannot imagine that that is what your teacher wants you to do ... in an exercise on sorting algorithms.
I expect that what your teacher actually means is that your implementations of QuickSort and MergeSort should not use any library packages.
But seriously, if you want clarification of the requirements for your homework, the only people who can actually do that are your teacher and their assistants.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论