Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

运行时错误? #45

Closed
zgjava opened this issue Apr 21, 2012 · 8 comments
Closed

运行时错误? #45

zgjava opened this issue Apr 21, 2012 · 8 comments

Comments

@zgjava
Copy link

zgjava commented Apr 21, 2012

#include < stdio.h >
int main()
{
    int i;
    char c;
    char c1[81],c2[81];
    printf("input cipher code:");
    for(i=0;(c=getchar())!='\n';i++)
    {
        c1[i]=c;
        if((c>='A'&&c<='Z')||(c>='a'&&c<='z'))
        {
            if(c>='A'&&c<='Z')
                c=(90+65)-c;
            else c=122+97-c;
            c2[i]=c;
        }
        else c2[i]=c;
    }
    c1[i]='\0';
    c2[i]='\0';
    printf("\ncipher code  :%s", c1);
    printf("\noriginal text:%s\n",c2);
    return 0;
}

该程序本地VC下运行正确,上传后出现运行时错误,不知为什么?

@sunner
Copy link
Member

sunner commented Apr 24, 2012

Please provide more details. Such as the configure of onlinejudge assignment

@zgjava
Copy link
Author

zgjava commented Apr 24, 2012

[root@localhost zgjava]# cc -v
使用内建 specs。
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-redhat-linux/4.6.0/libexec/gcc/x86_64-unknown-linux-gnu/4.6.0/lto-wrapper
目标:x86_64-unknown-linux-gnu
配置为:../gcc-4.6.0/configure --prefix=/usr/lib/gcc/x86_64-redhat-linux/4.6.0/ --with-gmp=/usr/local/lib/gmp-5.0.2/ --with-mpfr=/usr/local/lib/mpfr-3.0.1/ --with-mpc=/usr/local/lib/mpc-0.9/ --mandir=/usr/sharegcc-4.6.0/man --infodir=/usr/share/gcc-4.6.0/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,go --disable-dssi --enable-plugin --with-cpu=generic
线程模型:posix
gcc 版本 4.6.0 (GCC)
[root@localhost zgjava]# uname -a
Linux localhost 2.6.18-238.12.1.el5 #1 SMP Tue May 31 13:22:04 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux

@zgjava
Copy link
Author

zgjava commented Apr 24, 2012

测试用例:
输入:I am a teacher!
输出:
input cipher code:
cipher code :I am a teacher!
original text:R zn z gvzxsvi!

@sunner
Copy link
Member

sunner commented Apr 24, 2012

I means the configure/settings of the onlinejudge assignment activity in moodle

@zgjava
Copy link
Author

zgjava commented Apr 24, 2012

最多可用内存(MB)
local_onlinejudge | maxmemlimit
默认:64
一个被测程序最多可以使用多少内存。

最多可用CPU时间(秒)
local_onlinejudge | maxcpulimit
默认:10
一个被测程序最多可以运行多长时间。

发往ideone.com的访问请求之间的时间间隔(秒)
local_onlinejudge | ideonedelay
默认:10
向ideone.com发送评测请求和查询结果之间如何间隔太短,会被拒绝访问。这个间隔应该多大?

缺省语言
C(本地运行)

@sunner
Copy link
Member

sunner commented Apr 25, 2012

Which language(ideone/local) is this assignment using?

@zgjava
Copy link
Author

zgjava commented Apr 25, 2012

C(本地运行)

@sunner
Copy link
Member

sunner commented Apr 25, 2012

If you do not give a '\n' in the input of testcase, the program will be infinite loop and access beyond the border of c1 and c2.

For getchar(), the return value EOF should always be processed

@sunner sunner closed this as completed Apr 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants