#include void shift(int *a, int n); int main() { FILE* in = fopen("input.txt", "r"); if (in == NULL) { perror("Cannot open input file"); return -1; } int x; int n = 0; while (fscanf(in, "%d", &x) == 1) { ++n; } fseek(in, 0, SEEK_SET); if (n == 0) { fprintf(stderr, "Empty input file.\n"); return -1; } int *a = new int[n]; int m = 0; for (int i = 0; i < n; ++i) { if (fscanf(in, "%d", &(a[i])) == 1) { ++m; } } fclose(in); shift(a, m); FILE* out = fopen("output.txt", "w"); if (in == NULL) { perror("Cannot open output file"); return -1; } for (int i = 0; i < m; ++i) { if (i > 0) { if (i % 10 == 0) fprintf(out, "\n"); else fprintf(out, " "); } fprintf(out, "%d", a[i]); } fprintf(out, "\n"); fclose(out); return 0; } void shift(int *a, int n) { int j = n-1; double x = a[j]; while (j > 0) { a[j] = a[j-1]; --j; } a[0] = x; }