小编Rob*_*lin的帖子

定时功能时如何使用timeit

首先让我说我几乎不了解python,但必须用三种不同的语言编写程序(已经用java和c ++完成).

我需要能够为方法执行一定次数的时间,然后打印整个执行时间所花费的时间.

我有功能A(这是performSearch(arrayTest)其中arrayTest是已知大小的阵列).A执行10次

我需要能够计算从A执行之前到执行之后需要多长时间A.

python timeit

8
推荐指数
2
解决办法
7382
查看次数

在读取文件时使用分隔符

我几乎没有使用分隔符的经验,我需要读取一个文本文件,该文件存储多个对象,其数据以逗号(",")分隔的单行存储.然后使用单独的字符串创建一个添加到arraylist的新对象.

Amadeus,Drama,160 Mins.,1984,14.83
As Good As It Gets,Drama,139 Mins.,1998,11.3
Batman,Action,126 Mins.,1989,10.15
Billy Elliot,Drama,111 Mins.,2001,10.23
Blade Runner,Science Fiction,117 Mins.,1982,11.98
Shadowlands,Drama,133 Mins.,1993,9.89
Shrek,Animation,93 Mins,2001,15.99
Snatch,Action,103 Mins,2001,20.67
The Lord of the Rings,Fantasy,178 Mins,2001,25.87
Run Code Online (Sandbox Code Playgroud)

我使用Scanner读取文件,但是我发现没有找到行错误,整个文件存储在一个字符串中:

Scanner read = new Scanner (new File("datafile.txt"));
read.useDelimiter(",");
String title, category, runningTime, year, price;

while (read.hasNext())
{
   title = read.nextLine();
   category = read.nextLine();
   runningTime = read.nextLine();
   year = read.nextLine();
   price = read.nextLine();
   System.out.println(title + " " + category + " " + runningTime + " " +
                      year + …
Run Code Online (Sandbox Code Playgroud)

java delimiter

7
推荐指数
3
解决办法
7万
查看次数

"表达式必须具有类类型"错误是什么意思?

#include <cstdlib>
using namespace std;

int main()
{
    int arrayTest[512];
    int size = arrayTest.size();
    for(int a = 0;a<size;a++)
    {
         //stuff will go here
    }
}
Run Code Online (Sandbox Code Playgroud)

我在这里做错了什么,因为计划是用一些数字填充数组

c++ arrays

3
推荐指数
2
解决办法
2万
查看次数

错误,不允许不完整的类型

#include "passenger.h"
class node
{
public:
    passenger dataItem;
    node nextNode;
};
Run Code Online (Sandbox Code Playgroud)

为什么在尝试创建其类型为其所在类的变量时会出现不完整类型不允许错误?

c++

0
推荐指数
1
解决办法
2565
查看次数

标签 统计

c++ ×2

arrays ×1

delimiter ×1

java ×1

python ×1

timeit ×1