Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- FILE *fin = fopen("input.txt", "r");
- FILE *fout = fopen("output.txt", "w");
- int N, a[100];
- fscanf(fin, "%d", &N);
- for (int i = 0; i < N; i++) {
- fscanf(fin, "%d", &a[i]);
- }
- for (int i=0; i < N-2; i++) {
- while (((a[i] >= a[i + 1]) && (a[i + 2] <= a[i+1])) || ((a[i] <= a[i + 1]) && (a[i + 2] <= a[i+1]))) {
- if ((a[i] >= a[i + 1]) && (a[i + 2] <= a[i+1])) {
- a[i+2]++;
- }
- if ((a[i] <= a[i + 1]) && (a[i + 2] >= a[i+1])) {
- a[i]++;
- }
- }
- }
- for (int i=0; i<N; i++) {
- fprintf(fout, "%d ", a[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement