Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main() {
- FILE* fp;
- fp = fopen("input.txt", "r");
- int max = 0;
- int count = 0;
- int k[100];
- char n[100];
- n[0] = '\0';
- int min = 1000000;
- char ch;
- int f = 0;
- int countn = 0;
- int fl = 0;
- while ((ch = fgetc( fp)) != EOF)
- {
- if (ch == ' ' || ch == '\n' || ch == '\r') {
- if (fl == 1) {
- n[f ] = '\0';
- k[count] = atoi(n);
- if (k[count] > max)
- {
- max = k[count];
- }
- if (k[count] < min)
- {
- min = k[count];
- }
- f = 0;
- n[0] = '\0';
- count++;
- }
- if (ch == '\n')
- {
- countn++;
- if (countn == 2)
- {
- break;
- }
- }
- continue;
- }
- else {
- n[f] = ch;
- if (f == 99) break;
- f++;
- fl = 1;
- }
- }
- for (int i = 1; i < k[0] ; ++i)
- {
- if (k[i] == max)
- {
- k[i] = min;
- }
- printf("%i ", k[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement