Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Zadanie 1
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- int A[25];
- fstream plik("dane.txt",ios::out);
- for(int i=1;i<=25;i++)
- {
- plik << i <<" ";
- }
- plik.close();
- plik.open("dane.txt",ios::in);
- for(int i=0;i<25;i++)
- {
- plik >> A[i];
- cout << A[i] << " ";
- }
- plik.close();
- return 0;
- }
- Zadanie 2
- #include <iomanip>
- #include <iostream>
- #include <fstream>
- using namespace std;
- void in_tab(double A[4][4])
- {
- ifstream plik("ulamki.txt");
- for(int i=0;i<4;i++)
- {
- for(int j=0;j<4;j++)
- {
- plik >> A[i][j];
- }
- }
- plik.close();
- }
- void display(double A[4][4])
- {
- for(int i=0;i<4;i++)
- {
- for(int j=0;j<4;j++)
- {
- cout<<setw(8)<<A[i][j]<<" ";
- }
- cout<<endl;
- }
- }
- void fill_B(double A[4][4], double B[4][4])
- {
- for(int i=0;i<4;i++)
- {
- for(int j=0;j<4;j++)
- {
- B[i][j]=(int)A[i][j];
- }
- }
- }
- void to_file(double B[4][4])
- {
- ofstream plik("liczby.txt");
- for(int i=0;i<4;i++)
- {
- for(int j=0;j<4;j++)
- {
- plik << setw(4) << B[i][j] << " ";
- }
- plik << endl;
- }
- plik.close();
- }
- int main()
- {
- double A[4][4], B[4][4];
- in_tab(A);
- display(A);
- fill_B(A,B);
- to_file(B);
- return 0;
- }
- Zadanie 3
- #include <iomanip>
- #include <iostream>
- #include <fstream>
- using namespace std;
- int bit_change(int liczba, int n, char znak)
- {
- switch(znak)
- {
- case '0':
- return liczba & ~ (1 << n);
- case '1':
- return liczba & ~ (1 << n) | 1 << n ;
- case 'n':
- return liczba ^ 1 << n;
- }
- }
- int main()
- {
- cout<<bit_change(64,2,'n');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement