Created
July 15, 2020 00:18
-
-
Save anitainfo/0f0cb7ec85150bb2b9ada7d050789d22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> //biblioteca utilizada | |
using namespace std; | |
const int MAXN=10001; //define o valor de 'MAXN' como 100001 | |
int A[MAXN]; //define um vetor 'A' de tamanho 'MAXN' | |
int main() | |
{ | |
int N; //declara 'N | |
scanf("%d", &N); //leitura da entrada | |
for(int i=1; i<=N; i++) //loop para ler toda a entrada | |
{ | |
scanf("%d", &A[i]); //lê o valor e armazena no vetor 'A' com o índice da posição desse número na sequência dada | |
} | |
int soma=A[1]+A[N]; //define qual o valor da soma em que todos os valores "opostos" devem resultar quando somados | |
for(int i=1; i<=N; i++) //loop para verificar todos os pares de valores opostos | |
{ | |
if(A[i]+A[N-i+1] != soma) //se a soma de um dos pares for diferente da "padrão" ('soma') | |
{ | |
printf("N"); //imprimi N | |
return 0; //retorna a 0 (encerra) | |
} | |
} | |
printf("S"); //se todas as somas forem iguais a "padrão" ('soma'), imprimi S | |
return 0; //retorna a 0 (encerra) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment