Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <iostream>
- #include <stdio.h>
- #include <time.h>
- using namespace std;
- int main() {
- int flag = 1;
- bool read = true; //для проверки введенного числа
- int n = 0;
- while (true) { //зацикленная лаба, 0 - выход, что-то другое - продолжить
- printf("Enter 0 if you want to stop\n");
- scanf_s("%d", &flag);
- if (flag == 0) break;
- printf("Enter n in range (0,20]: ");
- read = true;
- while (read) { //проверка на корректность введенного значения
- scanf_s("%d", &n);
- if (n > 0 && n <= 20)
- read = false;
- else
- printf("\nWrong number, enter correct one: ");
- }
- printf("\nNumber\tIts square\n");
- for (int i = 1; i < 2*n; i = i+2) {
- printf("%d\t%d\n", i, i*i);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement