Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <sys/stat.h>
- struct answers_1{
- char* ans;
- };
- struct answers_1 get_file_name(int *mas, int x);
- int main (void)
- {
- struct answers_1 answers;
- char* path = (char*) malloc( 256 );
- int x = 0, buf = 0,i=0,b;
- printf("Input file name:\n");
- scanf("%s",path);
- FILE *in;
- in = fopen(path, "r");
- if (in == NULL) {
- exit(1);
- }
- while ((fscanf(in, "%d", &b)!=EOF)) {
- x++;
- }
- rewind(in);
- int mas[x];
- for(i=0;i<x;i++){
- fscanf(in, "%d", &buf);
- mas[i] = buf;
- }
- answers = get_file_name(mas,x);
- printf("%s\n", answers.ans);
- }
- struct answers_1 get_file_name(int *mas, int x){
- struct answers_1 answersf;
- answersf.ans = "YES";
- for(int i=0;i<x/2;i++){
- if (mas[i]!=mas[x-i-1]){
- answersf.ans = "NO";
- break;
- }
- }
- return answersf;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement