简体   繁体   English

ideone不显示任何输出

[英]ideone doesn't show any output

this code is of problem http://www.spoj.com/problems/BASE/ and it runs fine on windows and linux but when i run it on ideone it does not show me any output. 这段代码有问题http://www.spoj.com/problems/BASE/它在Windows和Linux上运行正常但是当我在ideone上运行它时它没有显示任何输出。 Can anyone tell me what is the reason behind this? 谁能告诉我这背后的原因是什么?

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<iostream>

using namespace std;

long int convert_base10(char *num, int base)
{
int len, dig;
long int result = 0;
len = strlen(num);
//    printf("len = %d\n", len);
// converting to base 10
for(int i=0; i<len; i++)
{
    if((num[len-i-1] >= 'A') && (num[len-i-1] <= 'F'))
        dig = num[len-i-1] - 55;
    else
        dig = num[len-i-1] - 48;
    result +=  (dig * pow(base, i));
  //        printf("num[%d] = %d\n", len-i-1, dig);
}
return result;
}

void convert_basei(long int num, int base, string &result1)
{
bool error = false;
int pos = 6;
char result[7], rem;
// initially storing space on all position
for(int i=0; i<7; i++)
    result[i] = ' ';
while(num)
{
    if((num % base) >= 10)
        rem = (num % base) + 55;
    else
        rem = (num % base) + 48;
    result[pos] = rem;//printf("result[%d] = %c\n", pos, rem);
    num /= base;//    printf("quotient = %d\n", num);
    pos--;
    if(pos < 0 && num > 0)
    {
        error = true;
        break;
    }

}
if(error == true)
   result1 = "  ERROR";
else
    result1 = result;
//    cout<<"result = "<<result1<<endl;
}

int main()
{
char num[7];
string result;
int base1, base2;
while(scanf("%s%d%d", num, &base1, &base2) == 3)
{
//        printf("num = %s\nbase1 = %d\nbase2 = %d\n", num, base1, base2);
    long int temp = convert_base10(num, base1);
//        printf("temp = %ld\n", temp);
    convert_basei(temp, base2, result);
    cout<<result<<endl;
}
return 0;
}

Replace this code: 替换此代码:

while(scanf("%s%d%d", num, &base1, &base2) == 3)
{
    long int temp = convert_base10(num, base1);
    convert_basei(temp, base2, result);
    cout<<result<<endl;
}

With this code, and the mystery will go away: 有了这段代码,神秘就会消失:

printf("trying to get input\n");
while(scanf("%s%d%d", num, &base1, &base2) == 3)
{
    printf("got some input\n");
    long int temp = convert_base10(num, base1);
    convert_basei(temp, base2, result);
    cout<<result<<endl;
}
printf("got no input\n");

I suspect a bug at ideone.com . 我怀疑ideone.com有一个错误。

I cloned your source and input, with a couple of minor adjustments and see no output at all. 我克隆了您的源和输入,进行了一些小的调整,根本看不到任何输出。 Since I expected to see some output, I've filed a report using the "report bug / make suggestion" link on the page. 由于我希望看到一些输出,我已经使用页面上的“报告错误/建议”链接提交了一份报告。

Then I cloned it again, made a few more stylistic changes and it gives the desired results. 然后我再次克隆它,做了一些更具风格的变化,它给出了预期的结果。


Response from Ideone 来自Ideone的回复

Date: Fri, 8 Mar 2013 12:18:49 +0100
From: Filip Wielewski <wiele@s...>
To: paj-ideone@j...
Cc: contact@i...
Subject: Re: Please see this question on StackOverflow for an explanation...

Hi [Johnsyweb],

thank you for letting us know about this issue. There is indeed
some problem with the original source code posted by Vijay Jain.
We will examine it and try to fix it very soon.

Regards,
Filip Wielewski
Ideone Team

2013/2/16 Ideone bug/suggestion <noreply@i...>

    Ideone bug/suggestion

    category: compiler/interpreter
    type: bug
    date: 2013-02-16 08:38:16
    user: johnsyweb
    e-mail: paj-ideone@j...
    site: http://ideone.com/Q8Kv9m
    compiler: C++ (ver: gcc-4.7.2, id: 1)
    description: Please see this question on StackOverflow for
    an explanation: http://stackoverflow.com/q/14907730/78845

    My response:
    http://stackoverflow.com/a/14908061/78845

    Regards;


    --paj

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM