Kosty_Fomin

Untitled

Nov 29th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <sys/stat.h>
  5.  
  6. struct answers_1{
  7.     char* ans;
  8. };
  9.  
  10. void  get_file_name(int *mas, int x);
  11.  
  12.  
  13. int main (void)
  14. {
  15.     //struct answers_1  answers;
  16.     char* path = (char*) malloc( 256 );
  17.     int x = 0, buf = 0,i=0,b;
  18.    
  19.     printf("Input file name:\n");
  20.     scanf("%s",path);
  21.    
  22.     FILE *in;
  23.     in = fopen(path, "r");
  24.    
  25.     if (in == NULL) {
  26.         exit(1);
  27.     }
  28.  
  29.    
  30.     while ((fscanf(in, "%d", &b)!=EOF)) {
  31.         x++;
  32.  
  33.     }
  34.     rewind(in);
  35.    
  36.    
  37.     int mas[x];
  38.  
  39.     for(i=0;i<x;i++){
  40.        
  41.         fscanf(in, "%d", &buf);
  42.         mas[i] = buf;
  43.        
  44.     }
  45.     get_file_name(mas,x);
  46.    
  47.     for(int i=0;i<x;i++){
  48.         printf("%d ", mas[i]);
  49.     }
  50.    
  51. }
  52.  
  53.  
  54.  
  55.  
  56. void  get_file_name(int *mas, int x){
  57.    
  58.     int a;
  59.    
  60.      for(int i=0;i<x/2;i++){
  61.  
  62.           a = mas[i];
  63.          mas[i] = mas[x-i-1];
  64.          mas[x-i-1] = a;
  65.          
  66.          
  67.  
  68. }
  69.    
  70.    
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment