Commit 6437af3c by Patryk Czarnik

Zajęcia nr 4 - pierwsza pętla for

parent 2da5e37b
#include <iostream>
using namespace std;
int main()
{
cout << "POCZATEK" << endl;
for(int numer = 1; numer < 100; numer++) {
cout << "Wypisuje teraz linie nr " << numer << endl;
}
cout << "KONIEC" << endl;
return 0;
}
#include <iostream>
using namespace std;
/* Napisz program, ktory:
- wczytuje tekst od uzytkownika (najlepiej za pomoca getline)
- pyta ile razy ten tekst powtorzyc
- tyle razy, ile podal czlowiek, wypisuje tekst na ekran
*/
int main()
{
string tekst;
int ile_razy;
cout << "Podaj tekst:\n";
getline(cin, tekst);
cout << "Ile razy powtorzyc? ";
cin >> ile_razy;
for(int numer = 0; numer < ile_razy; numer++) {
cout << tekst << endl;
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
string nazwa;
double cena;
int ilosc;
cout << "Co chcesz kupic? ";
// cin >> nazwa; // pojedyncze slowo
getline(cin, nazwa); // jesli chcecie wczytac cala linie tekstu
cout << "Ile kosztuje jedna sztuka towaru " << nazwa << "? ";
cin >> cena;
cout << "Ile sztuk kupujesz? ";
cin >> ilosc;
double wartosc = cena * ilosc;
cout << "Za " << ilosc << " sztuk towaru " << nazwa << " zaplacisz " << wartosc << endl;
if(wartosc >= 1000)
{
cout << "Duzo kasy wydajesz" << endl;
}
return 0;
}
\ No newline at end of file
#include <iostream>
using namespace std;
int main()
{
double cena;
int ilosc;
cout << "Jak jest cena? ";
cin >> cena;
cout << "Ile sztuk kupujesz? ";
cin >> ilosc;
double wartosc = cena * ilosc;
cout << "Do zaplaty: " << wartosc << endl;
if(wartosc >= 1000)
{
cout << "Duzo kasy wydajesz" << endl;
}
return 0;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment