Page 1 of 1

11764 - Jumping Mario

Posted: Mon Sep 24, 2012 7:16 am
by tarsun
Why WA?????

Code: Select all

  #include<stdio.h>

int main()
{
    int test,i,w,j,size[100],low,high,k;
    scanf("%d",&test);
    if(test<30)
    {
    for(i=1;i<=test;i++)
    {

	scanf("%d",&w);
	if((w>0)&&(w<50))
	{
	low=0;
	high=0;
	for(j=1;j<=w;j++)
		scanf("%d",&size[j]);
	for(k=1;k<w;k++)
	{
	if(size[k]<size[k+1])
		high=high+1;
	else if(size[k]==size[k+1])
	;
	else
		low=low+1;
	}
	printf("\nCase %d: %d %d",i,high,low);

	}



    }
   }
    return 0;
}

Re: 11764 - Jumping Mario

Posted: Wed Mar 18, 2015 4:59 pm
by aleksamarkoni
You have the problem with two w, both loops are using w, insted the first one should use test.

Re: 11764 - Jumping Mario

Posted: Wed Nov 18, 2015 7:30 am
by tamal_5th_gen
please help me find out the problem in this code

Code: Select all

#include<iostream>
using namespace std;
int main()
{
    int t,k;
    cin>>t;
    for(k=1; k<=t; k++)

    {
        int n,up=0,down=0;
        cin>>n;
        if(n!=0)
        {
            int i,h[n-1];
                for(i=0; i<n; i++)
                {
                    cin>>h[i];

                }
            if(n<=1)
            {
                cout<<"case "<<k<<": "<<up<<" "<<down<<endl;

            }
            else
            {

                for(i=0; i<n-1; i++)
                {
                    if(h[i+1]>h[i])
                    {
                        up++;

                    }
                    else if(h[i+1]==h[i])
                    {
                        continue;
                    }
                    else
                    {
                        down++;

                    }
                }
                cout<<"case "<<k<<": "<<up<<" "<<down<<endl;
            }

        }
        else
        {
            cout<<"case "<<k<<": "<<up<<" "<<down<<endl;
        }

    }
    return 0;
}