标签: runtime-error

字符串数据类型为 C++ 程序中的特定测试用例创建运行时错误

对于codeforces问题:

https://codeforces.com/problemset/problem/339/A

以下程序在第七次测试中显示运行时错误:

#include<iostream>
using namespace std;

int main()
{
    char s[100];
    cin>>s;
    int i;
    string a,b,c;
    int j=0,k=0,l=0;
    for(i=0;s[i]!='\0';i++)
    {
        if(s[i]=='1')
        {
            a[j]='1';
            a[j+1]='+';
            j+=2;
        }

        if(s[i]=='2')
        {
            b[k]='2';
            b[k+1]='+';
            k+=2;
        }

        if(s[i]=='3')
        {
            c[l]='3';
            c[l+1]='+';
            l+=2;
        }
    }
    char str[100];
    int x,y,z;
    for(x=0;x<=j-1;x++)
    {
        str[x]=a[x];
    }

    for(y=0;y<=k-1;y++,x++)
    {
        str[x]=b[y];
    }

    for(z=0;z<=l-1;z++,x++)
    {
        str[x]=c[z];
    }

    int q;
    for(q=0;q<=x-2;q++)
    {
        cout<<str[q];
    }

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

测试用例是:

2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+ 3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1

string a,b,c;当我更改为时答案被接受char a[100],b[100],c[100];

我无法理解为什么string这里的数据类型导致运行时错误。

我猜这可能是由于测试用例的长度造成的,但我不确定为什么。

c++ arrays string runtime-error c++17

-1
推荐指数
1
解决办法
49
查看次数

尽管所有参数都是纯字符串,但无法连接“str”和“Nontype”对象错误

我正在编写这个 python 程序,我随机收到了这个非常令人困惑的错误。这是我的脚本的一部分:

部分代码ai.py(从第 133 行开始)

elif (config.var0 < config.var1):                   
    message = "SUCCESS_0021! var0 successfully adjusted."
    print message
    aux_func.write_log(message)
    config.var0 = float(config.var1)
    config.ask_trail = (1.0 + config.var2) * config.var3
Run Code Online (Sandbox Code Playgroud)

文件中的write_log函数aux_func.py看起来像这样的起始行 #43

def write_log (message):
    log_file = open(current_dir + '//logs//' + date_stamp(), 'a+')
    temp_write = "\n " + time_stamp() + " : " + str(message)
    log_file.write(temp_write)
    log_file.close()
Run Code Online (Sandbox Code Playgroud)

这工作得很好,并且在大多数情况下按预期写入日志文件。但是,当我运行此脚本一段时间时,控制台会显示以下奇怪的消息:

Traceback <most recent call last):
  File "main1.py", line 102, in <module>
    func_flag = ai.decide()
  File "C:\project\ai.py", line …
Run Code Online (Sandbox Code Playgroud)

python string runtime-error

-2
推荐指数
1
解决办法
622
查看次数

TypeError:'NoneType'对象在函数内没有属性'__getitem__'变量值

我已将变量fiblist声明为全局变量,但它在gen10fib中获得None的值.

# Enter your code here. Read input from STDIN. Print output to STDOUT
#program to check if a number is fibonacci number

global fiblist 
fiblist=[0,1] #list to store generated fibonacci numbers

global Nlist
Nlist=[] # list for T test cases

global solnList
solnList=[] #contains the solution 1 is fibo 0 not fibo

global head
head=1 #to denote the maximum element in the list

def comparator(fiblist,x,head):


    if(head<x):


        gen10fib(fiblist) #generates the next 10 numbers of fibonacci sequence and appends them to …
Run Code Online (Sandbox Code Playgroud)

python runtime-error nonetype

-2
推荐指数
1
解决办法
539
查看次数

内核启动失败:参数无效,CUDA运行时错误

我正在尝试在随附的代码中启动内核。我收到消息“内核启动失败:参数无效”。

// System includes
#include <stdio.h>
#include <assert.h>

// CUDA runtime
#include <cuda_runtime.h>

// Helper functions and utilities to work with CUDA
#include <helper_functions.h>

// This will output the proper CUDA error strings in the event that a CUDA host call returns an error
#define checkCudaErrors(err)  __checkCudaErrors (err, __FILE__, __LINE__)

inline void __checkCudaErrors(cudaError err, const char *file, const int line )
{
    if(cudaSuccess != err)
    {
        fprintf(stderr, "%s(%i) : CUDA Runtime API error %d: %s.\n",file, line, (int)err, cudaGetErrorString( err ) …
Run Code Online (Sandbox Code Playgroud)

cuda runtime-error

-2
推荐指数
1
解决办法
5710
查看次数

如何修复运行时错误“您必须提供 layout_width 属性。” 在安卓中?

我有一个在 AndroidStudio 中编译的 android 应用程序,但是当我调用某个活动时,我收到以下错误:

11-22 16:08:40.461 13796-13796/com.impyiablue.stoxx E/AndroidRuntime: FATAL EXCEPTION: main
                                                                      Process: com.impyiablue.stoxx, PID: 13796
                                                                      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.impyiablue.stoxx/com.impyiablue.stoxx.EditEntryActivity}: java.lang.RuntimeException: Binary XML file line #25: You must supply a layout_width attribute.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by: java.lang.RuntimeException: Binary XML file line #25: You must supply a layout_width attribute.
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:606)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:6422)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:6591)
at android.widget.LinearLayout$LayoutParams.<init>(LinearLayout.java:1866)
at …
Run Code Online (Sandbox Code Playgroud)

android runtime-error

-2
推荐指数
1
解决办法
2250
查看次数

c.programing,代码剂量工作

我的程序是检查一个数字是否是一个完美的数字我有一个运行时错误请帮助我和我使用记事本++如果它重要

#include <stdio.h>

int main(void)
{
    int input=0;
    int i=0;
    int counter=0;

    printf("enter a number \n");
    scanf("%d", &input);
    for (i=0;i<=input;i++)
    {
        if (input%i==0)
        {
            counter = counter+i;
        }
    }
    if (input==counter)
    {
        printf("%d in a perfect number\n", counter);
    }
    else
    {
        printf("%d is not a perfect number\n", input);
    }
    system("pause");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c runtime-error

-2
推荐指数
1
解决办法
37
查看次数

运行时错误:imageio.ffmpeg.download() 已被弃用。改用“pip install imageio-ffmpeg”。

我正在尝试使用 Jupiter 笔记本从这里运行车道检测项目。我得到这个运行时错误:

错误图片

当我尝试运行此代码时:

# Import everything needed to edit/save/watch video clips
from moviepy.editor import VideoFileClip
from IPython.display import HTML
Run Code Online (Sandbox Code Playgroud)

我已经尝试安装最新版本的moviepywith conda install -c conda-forge moviepy。我也尝试使用 pip 安装,但仍然出现相同的错误。

python runtime-error moviepy python-imageio

-2
推荐指数
1
解决办法
3586
查看次数

修复IE8中的"未知运行时错误"

我没有看到其他人真正想要实现我的目标...人们想要通过innerHTML属性替换一些节点但是,我不仅想要这样做,而且我还想用javascript替换它.

下面是我的示例脚本是在Firefox的所有版本中工作正常: http://syn4k.site90.net/working_test/ 编辑:如果上面的链接不起作用,试试这个:HTTP://www.syn4k.freehosting .COM/working_test /

你会注意到它在IE8中不起作用.我猜它不适用于任何版本的IE ...

我在链接上创建的过程很简单:1.用户点击进入该过程.2.打开一个新窗口.3.来自新窗口的数据被发送回开启器并插入到DOM中.3.note.发回的数据是javacript,应该像在Firefox中一样执行.

html javascript runtime-error innerhtml

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

程序不起作用 - NullPointerException

我使用eclipse将我的项目导出为可运行的jar文件,当我尝试运行时没有任何反应,当我使用cmd运行它时,我得到了这个错误.

C:\Users\Enes\Desktop>cmd.exe
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Enes\Desktop>java -jar Game.Jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.NullPointerException
        at scrolls.Resources.createArray(Resources.java:111)
        at scrolls.Player.<init>(Player.java:31)
        at scrolls.Draw.<init>(Draw.java:27)
        at scrolls.Frame.main(Frame.java:18)
        ... 5 more

C:\Users\Enes\Desktop>
Run Code Online (Sandbox Code Playgroud)

当我使用eclipse运行它时,运行正常,没有错误或警告.

这是我的资源文件,似乎在第111行引起了问题

package scrolls;

import java.awt.Font;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.imgscalr.Scalr;

public class Resources
{
    Map map; …
Run Code Online (Sandbox Code Playgroud)

java eclipse runtime-error nullpointerexception

-3
推荐指数
1
解决办法
428
查看次数

在调试时获得错误"算术异常"

在回答这个问题时,我尝试运行此代码(用于生成给定范围内的随机数);

#include<stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <time.h>

int main()
{

    int max_range, i = 0, rand_num;
    bool digit_seen[max_range + 1]; // VLAs For C99 only 

    srand((unsigned)time(NULL));
    printf("Enter your maximum of range: ");
    scanf("%d", &max_range);

    for (int i = 1; i <= max_range; i++)
        digit_seen[i] = false;  

    for (;;)
    {  
         rand_num = rand() % max_range + 1;
         if(rand_num !=3)
             if(!digit_seen[rand_num])
             {
                printf("%d ", rand_num);
                digit_seen[rand_num] = true;
                i++;
             }
         if( i == (max_range - 1) )
             exit(0);
    } …
Run Code Online (Sandbox Code Playgroud)

c debugging runtime-error

-3
推荐指数
1
解决办法
2826
查看次数