Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void init(FILE* f)
- {
- srand(time(0));
- int cnt = 10;
- int n = 2;
- int* ar = new int[cnt];
- for(int i = 0; i < cnt; i++) ar[i] = rand() % 100;
- fwrite(&cnt, sizeof(int), 1, f);
- fwrite(ar, sizeof(int), cnt, f);
- fwrite(&n, sizeof(int), 1, f);
- for(int i = 0; i < cnt; i++) cout << ar[i] << " "; cout << "\n";
- delete[] ar;
- }
- int main()
- {
- FILE* tf = fopen("input.txt", "wb");
- init(tf);
- fclose(tf);
- tf = fopen("input.txt", "rb");
- int cnt;
- int n;
- int* ar;
- fread(&cnt, sizeof(int), 1, tf);
- ar = new int[cnt];
- fread(ar, sizeof(int), cnt, tf);
- fread(&n, sizeof(int), 1, tf);
- for(int i = 0; i < cnt; i++) if(ar[i] % n) cout << ar[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement