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;
- };
- void 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;
- }
- get_file_name(mas,x);
- for(int i=0;i<x;i++){
- printf("%d ", mas[i]);
- }
- }
- void get_file_name(int *mas, int x){
- int a;
- a = mas[x-1];
- for(int i=x-1;i>0;i-=1){
- mas[i] = mas[i-1];
- }
- mas[0] = a;
- }
Advertisement
Add Comment
Please, Sign In to add comment