## 11764 - Jumping Mario

Moderator: Board moderators

tarsun
New poster
Posts: 7
Joined: Thu Sep 20, 2012 7:58 pm
Contact:

### 11764 - Jumping Mario

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;
}``````
aleksamarkoni
New poster
Posts: 1
Joined: Wed Mar 18, 2015 4:56 pm

### Re: 11764 - Jumping Mario

You have the problem with two w, both loops are using w, insted the first one should use test.
tamal_5th_gen
New poster
Posts: 2
Joined: Mon Nov 16, 2015 3:20 pm

### Re: 11764 - Jumping Mario

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;
}``````