Input:
Code: Select all
6 46 25 73 71 30 78
2 15 25
Code: Select all
Case #1: 46 25 73 71 30 78
This is not an A-sequence.
Case #2: 15 25
This is an A-sequence.
Moderator: Board moderators
Code: Select all
6 46 25 73 71 30 78
2 15 25
Code: Select all
Case #1: 46 25 73 71 30 78
This is not an A-sequence.
Case #2: 15 25
This is an A-sequence.
Code: Select all
Got AC.
Code: Select all
#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;
}
Code: Select all
3 4 336 34
Code: Select all
Case #1: 4 336 34
This is an A-sequence.
Code: Select all
Case #1: 4 336 34
This is not an A-sequence.
i put return 0; but again shows "the execution of your program didn't finish properly. Remember to always terminate your code with the exit code 0."brianfry713 wrote:put this line at the end of your code.
return 0;