Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- void test_for() {
- // числа от 0 до 9
- for (int k = 0; k <= 9; k++) {
- cout << k << " ";
- }
- cout << endl;
- int k = 0;
- while (k <= 9) {
- cout << k << " ";
- k++;
- }
- }
- void draw_rectangle() {
- int width = 8;
- int heigth = 5;
- for (int y = 0; y < heigth; y++) {
- for (int x = 0; x < width; x++) {
- bool is_border1 = y == 0 || x ==0 ;
- bool is_border2 = y == heigth - 1 ||
- x == width - 1;
- if (is_border1 || is_border2) {
- cout << "$ ";
- }
- else {
- cout << " ";
- }
- }
- cout << endl;
- }
- }
- void pentagon() {
- const int n = 5;
- double perimetr = 0;
- double side;
- for (int k = 0; k < 5; k++) {
- cout << "Enter side " << k+1 << " : ";
- cin >> side;
- perimetr += side;
- }
- cout << "Perimert: " << perimetr << endl;
- }
- void guess_number() {
- int number_ai = rand() % 500 + 1;
- int number_human;
- cout << " GUESS THE NUMBER\n";
- cout << " Я загадал число от 1 до 500, "
- << "попробуй его угадать.\n";
- int raund = 0;
- do {
- cin >> number_human;
- raund++;
- if (number_human != number_ai) {
- if (number_ai > number_human) {
- cout << "Моё число больше ";
- }
- else {
- cout << "Моё число меньше ";
- }
- cout << number_human << endl;
- }
- else {
- cout << "Вы угадали за " << raund << " ходов.\n";
- break;
- }
- } while (number_human > 0);
- ///
- }
- void test_break() {
- for (int k = 0; k < 10; k++) {
- cout << k << " ";
- if (k == 5) break;
- }
- cout << endl;
- for (int k = 0; k < 10; k++) {
- if (k == 5) continue;
- cout << k << " ";
- }
- cout << endl;
- }
- void test_rand() {
- int n;
- for (int k = 0; k < 10; k++) {
- n = rand() % 500 + 1;
- cout << n << endl;
- }
- }
- int main() {
- setlocale(LC_ALL, "ru");
- cout << "time " << time(NULL);
- srand(time(NULL));
- //test_break();
- guess_number();
- //test_for();
- //pentagon();
- //draw_rectangle();
- //test_rand();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement