Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Zadanie 1
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- #include <fstream>
- using namespace std;
- int main() //
- {
- ofstream zapis_do_pliku("plik.txt");
- srand( time ( NULL ) );
- int i;
- for (int i = 1; i<=10; i++)
- {
- zapis_do_pliku<<rand() % 30 + 1;
- }
- return 0;
- }
- Zadanie 2
- #include <iostream>
- #include <fstream>
- using namespace std;
- string imie;
- string miejscowosc;
- int numer_telefonu;
- int main()
- {
- ofstream operacje("operacje.txt", ios::app);
- cout <<"Wpisz imie"<<endl;
- cin>> imie;
- cout<< "Wpisz miejscowosc"<<endl;
- cin>> miejscowosc;
- cout<< "Wpisz numer telefonu"<<endl;
- cin>> numer_telefonu;
- operacje<<imie<<endl;
- operacje<<miejscowosc<<endl;
- operacje<<numer_telefonu<<endl;
- return 0;
- }
- 3.)
- #include <iostream>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- int main() {
- ofstream zapis_do_pliku("dane.txt");
- int tab[10][10];
- for (int i = 0; i < 10; i++) {
- for (int x = 0; x < 10; x++) {
- tab[i][x] = (i + 1) * (x + 1);
- zapis_do_pliku << setw(4) << tab[i][x] << " ";
- }
- zapis_do_pliku << endl;
- }
- return 0;
- }
- Zadanie 5
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- int a =0;
- string x;
- ifstream wiersz ("wiersz.txt");
- while(getline(wiersz,x))
- {
- if(a%2==0)
- {
- cout<<x<<endl;
- }
- a++;
- }
- return 0;
- }
- Zadanie 6
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- int a =0;
- string x;
- ifstream wiersz ("wiersz.txt");
- while(getline(wiersz,x))
- {
- if(a%3==0)
- {
- cout<<x<<endl;
- }
- a++;
- }
- return 0;
- }
- Zad 7
- #include <iostream>
- #include <fstream>
- using namespace std;
- string x;
- int main()
- {
- ofstream nazwa ("dane.txt");
- if (!nazwa.is_open())
- {
- cout<<"Brak dostepu do pliku";
- }
- nazwa<<"Filip"<<endl;
- nazwa<<"Kinderman"<<endl;
- nazwa<<18<<endl;
- ifstream nazwa1 ("dane.txt");
- nazwa1.seekg(7,ios::beg);
- while(getline(nazwa1,x))
- {
- cout<<x<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment