我在本实验中的任务是接受多个输入文件,并且所有这些文件的格式都相似,只是有些文件有注释,我想跳过注释行.例如:
输入文件:
Input file 1
#comment: next 5 lines are are for to be placed in an array
blah 1
blah 2
blah 3
blah 4
blah 5
#comment: next 2 line are to be placed in a different array
blah 1
blah 2
#end of input file 1
Run Code Online (Sandbox Code Playgroud)
我尝试做的是我使用2循环(如果需要,我可以发布我的代码).我做了以下
while(s.hasNext()) {
while(!(s.nextLine().startWith("#")) {
//for loop used to put in array
array[i] = s.nextLine();
}
}
Run Code Online (Sandbox Code Playgroud)
我觉得这应该有效,但事实并非如此.我做错了什么 请帮忙.先感谢您.
我被要求创建一个有条件的队列类,其条件如下:
仅使用基本类型,实现有界队列以存储整数.应针对算法运行时,内存使用和内存吞吐量优化数据结构.不应导入和/或使用外部库.解决方案应该在一个提供以下功能的类中提供:
我写了这个课程,但我想通过让某人测试它以及看它是否正常工作来寻求帮助.我写了一个小的主要类来测试它,一切似乎都在工作但我想在提交它之前想看另一双眼睛.它是为了实习.先感谢您.
public class Queue<INT>
{
int size;
int spacesLeft;
int place= 0;
int[] Q;
public Queue(int size)
{
this.size = size;
spacesLeft = size;
Q = new int[size];
}
//enqueue - function should take an integer and store it in the queue if the queue isn't full.
//The function should properly handle the case where the queue is already full
public void enque(int newNumber) throws Exception
{
if(place <= …Run Code Online (Sandbox Code Playgroud)