#include <stdio.h> #include <stdlib.h> int main() { FILE *fp; fp = fopen("file.txt", "w+"); int i; int pi[100]; int pos, neg; for(i = 0, pos = -5, neg = 0; i < 20; i++){ if(i % 2 == 0){ pos += 10; fprintf(fp, "%d," ,pos); }else { neg -= 10; fprintf( fp, "%d," ,neg); } } int j = 0; char c; rewind(fp); while(!feof(fp)){ fscanf(fp, "%d," ,&i ); pi[j] = 3 * i; j++; rewind(fp); for(j = 0; j < 20; j++){ fprintf( fp, "%d," ,pi[j]); } return 0; } —
Igor 7 mins ago