Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using namespace std;
- int main()
- {
- srand(time(NULL));
- int n;
- cout << "Podaj ilosc losowanych iczb: " << endl;
- cin >> n;
- FILE *plik = nullptr;
- int dane;
- char znak;
- if ((plik = fopen("losowanie.txt", "w+")) != nullptr)
- {
- for (int i = 1; i <= n; ++i)
- fprintf(plik, " %d", rand() % 10);
- for (int i = 1; i <= n; ++i)
- {
- fseek(plik, -(i * 2), SEEK_END);
- fscanf(plik, "%d", &dane);
- cout << dane << " " ;
- }
- fclose(plik);
- }
- else
- cout << "Nie udalo sie otworzyc pliku na dysku!\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement