But I'm still W.A.
What is my problem with my code?
Please help me.
- Code: Select all
Got AC.
I solve this problem without sorting.
Because of sorting, I got WA.
Moderator: Board moderators
Got AC.
#include<stdio.h>
int main()
{
int tam,n=1;
while(scanf("%d",&tam)==1){
int aux=tam,vec[tam],indice=0,band=1;
while(aux--){
scanf("%d",&vec[indice]);
indice++;
}
if(vec[0]>=1);
else band=0;
for(int i=1;i<tam;i++){
if(vec[i]>vec[i-1]);
else band=0;
}
if(band==1 && tam>=3){
for(int i=2;i<tam;i++){
for(int j=0;j<i;j++){
for(int k=0;k<i;k++){
if(k!=j){
if(vec[j]+vec[k]==vec[i]){band=0; break;}
}
}
}
}
}
printf("Case #%d:",n);
for(int i=0;i<tam;i++)printf(" %d",vec[i]); puts("");
if(band==1){
puts("This is an A-sequence.");
}
else{
puts("This is not an A-sequence.");
}
n++;
}
return 0;
}
3 4 336 34 Case #1: 4 336 34
This is an A-sequence.Case #1: 4 336 34
This is not an A-sequence. Users browsing this forum: No registered users and 1 guest