| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哪位大神告知下,为什么会WA,脑子想爆了。。。#include<stdio.h>
#include<iostream>
using namespace std;
int main(void)
{
int line,n;
int i,j;
int count[10];
int a[10][20];
int b[10][20];
int sum=0;
int temp=0;
scanf("%d",&line);
for(i=0;i<line;i++)
{
scanf("%d",&n);
count[i]=n;
for(j=0;j<n;j++)
{
cin>>a[i][j];
}
}
for(i=0;i<line;i++)
{
for(j=0;j<count[i];j++)
{
if(j==0)
{
b[i][j]=1;
}
else
{
if(temp<0 && (a[i][j]>a[i][j-1]))
{
sum=0;
}
if(temp<0)
{
temp=0;
}
sum=sum+a[i][j]-a[i][j-1];
temp=temp+a[i][j]-a[i][j-1]-1;
if(a[i][j]!=a[i][j-1])
{
b[i][j]=1;
}
else
{
if(temp<0)
{
b[i][j]=j+1;
}
else
{
b[i][j]=sum-temp;
}
}
}
}
}
for(i=0;i<line;i++)
{
for(j=0;j<count[i];j++)
{
if(j!=count[i]-1)
{
printf("%d ",b[i][j]);
}
else
{
printf("%d",b[i][j]);
}
}
printf("\n");
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator