Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Wrong Answer Debugging

$
0
0

Hello, I've been getting wrong answer on these two problems : turbo sort and holes in the text. They run just fine on my compiler - I'm using xcode. Kindly help.

//Holes in the text

int main() { int t, i, j = 1; cin >> t; if (t > 40) return 1; char hole[100]; int count[40];

while (j <= t)
{
    scanf ("%s", hole);
    count[j] = 0;
    for (i = 0; i < 40; i++)
    {
        if (hole[i] == 'A' || hole[i] == 'D' || hole[i] == 'O' || hole[i] == 'P' || hole[i] == 'R' || hole[i] == 'Q')
            count[j]++;
        else if (hole[i] == 'B')
            count[j] += 2;

    }
    cout << count[j] << endl;
    j++;
}

/*for (j = 1; j <= t; j++)
 cout << count[j] << endl;*/

return 0;

}

//Turbo

long turbo[1000000] = {0};

int main() { long j, x = 0, i, p; long maxx = 0; cin >> j;

for (i = 0; i < j; i++)
{
    scanf("%ld", &x);
    if (x < 1000000)
    {
        turbo[x] = x;
        if (x > maxx)
        maxx = x;
    }
}

for (p = 0; p <= maxx; p++)
{
    if (turbo[p] > 0)
        printf ("%ld \n", turbo[p]);
}

return 0;

}


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>