Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Проверка строки на наличие нужных символов, цифр и тд.
- #include "iostream"
- #include "stdlib.h"
- using namespace std;
- int main(){
- system("chcp 1251 >nul");
- cout << "Введите текст: ";
- char buf[1024] = { 0 };
- cin.getline(buf, 1024, '\n');
- if (buf[0] == '\0') {
- cout << "Пустая строка - выход" << endl;
- return 0;
- }
- long val = atol(buf);
- cout << "Ввели число " << val << endl;
- system("pause");
- return 0;
- }
- ДЗ 1 задача вывести фигуры, недоделанная
- #include "iostream"
- #include "math.h"
- using namespace std;
- int main() {
- setlocale(LC_ALL, "rus");
- int num, sh, dl;
- cout << "Введите ширину фигуры" << endl;
- cin >> sh;
- cout << "Введите длину фигуры" << endl;
- cin >> dl;
- cout << "Введите номер фигуры, которую хотите отобразить" << endl;
- cin >> num;
- for (int i = 0; i <= dl; i++) {
- cout << endl;
- for (int j = 0; j <= sh; j++) {
- switch (num) {
- case 2: i > j ? cout << "*" : cout << " ";
- break;
- case 1: i < j ? cout << "*" : cout << " ";
- break;
- case 9: i < dl - j ? cout << "*" : cout << " ";
- break;
- case 10: dl - i < j ? cout << "*" : cout << " ";
- break;
- case 3: i <= j && j <= (sh - i)? cout << "*" : cout << " ";
- break;
- case 4: i >= j && j >= (sh - i)? cout << "*" : cout << " ";
- break;
- case 7: j <= i && i <= (sh - j) ? cout << "*" : cout << " ";
- break;
- case 8: j >= i && i >= (sh - j) ? cout << "*" : cout << " ";
- break;
- case 5: j >= (sh - i) && i >= (sh - j) && j >= i && i >= (sh - j)? cout << "*" : cout << " ";
- break;
- }
- }
- }return 0;
- }
Add Comment
Please, Sign In to add comment