Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int j[4][4],k[4][4],l1,l2,liczba,mnoznik;
- char wybor;
- start:
- cout << "Co chcesz zrobic?" <<endl;
- cout << "1. Dodawanie" << endl;
- cout << "2. Mnozenie" << endl;
- cout << "3. Wyjscie" << endl;
- cin >> wybor;
- switch(wybor)
- {
- case '1':
- {
- cout << "podaj pierwszy zestaw 16 cyfr" << endl;
- for (l1=0,liczba=1; l1<4; l1++)
- {
- for (l2=0; l2<4; l2++,liczba++)
- {
- cout << "wpiszujesz wiersz: " << l1+1 << " kolumne: " << l2+1 << " : ";
- cin >> j[l1][l2];
- }
- }
- cout << "podaj drugi zestaw 16 cyfr" << endl;
- for (l1=0,liczba=1; l1<4; l1++)
- {
- for (l2=0; l2<4; l2++,liczba++)
- {
- cout << "wpiszujesz wiersz: " << l1+1 << " kolumne: " << l2+1 << " : ";
- cin >> k[l1][l2];
- }
- }
- for (l1=0; l1<4; l1++)
- {
- for (l2=0; l2<4; l2++)
- {
- j[l1][l2]=j[l1][l2]+k[l1][l2];
- }
- }
- cout <<endl;
- for (l1=0; l1<4; l1++)
- {
- for (l2=0; l2<4; l2++)
- {
- cout.width(4);
- cout << j[l1][l2];
- }
- cout <<endl;
- }
- break;
- }
- case '2':
- {
- cout << "Wpisz zestaw do mnozenia"<<endl;
- for (l1=0,liczba=1; l1<4; l1++)
- {
- for (l2=0; l2<4; l2++,liczba++)
- {
- cout << "wpiszujesz wiersz: " << l1+1 << " kolumne: " << l2+1 << " : ";
- cin >> j[l1][l2];
- }
- }
- cout << "Wpisz mnoznik: ";
- cin >> mnoznik;
- for (l1=0; l1<4; l1++)
- {
- for (l2=0; l2<4; l2++)
- {
- j[l1][l2]=j[l1][l2]*mnoznik;
- }
- }
- for (l1=0; l1<4; l1++)
- {
- for (l2=0; l2<4; l2++)
- {
- cout.width(4);
- cout << j[l1][l2];
- }
- cout << endl;
- }
- break;
- }
- case '3':
- {
- return 0;
- }
- default:
- {
- system("cls");
- cout << "Niepoprawny wybor!" << endl;
- goto start;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement