Guest User

Untitled

a guest
Jan 18th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. Проверка строки на наличие нужных символов, цифр и тд.
  2. #include "iostream"
  3. #include "stdlib.h"
  4. using namespace std;
  5.  
  6. int main(){
  7. system("chcp 1251 >nul");
  8. cout << "Введите текст: ";
  9. char buf[1024] = { 0 };
  10. cin.getline(buf, 1024, '\n');
  11.  
  12. if (buf[0] == '\0') {
  13. cout << "Пустая строка - выход" << endl;
  14. return 0;
  15. }
  16. long val = atol(buf);
  17. cout << "Ввели число " << val << endl;
  18. system("pause");
  19. return 0;
  20. }
  21.  
  22. ДЗ 1 задача вывести фигуры, недоделанная
  23. #include "iostream"
  24. #include "math.h"
  25. using namespace std;
  26.  
  27. int main() {
  28. setlocale(LC_ALL, "rus");
  29. int num, sh, dl;
  30. cout << "Введите ширину фигуры" << endl;
  31. cin >> sh;
  32. cout << "Введите длину фигуры" << endl;
  33. cin >> dl;
  34. cout << "Введите номер фигуры, которую хотите отобразить" << endl;
  35. cin >> num;
  36.  
  37. for (int i = 0; i <= dl; i++) {
  38. cout << endl;
  39. for (int j = 0; j <= sh; j++) {
  40. switch (num) {
  41. case 2: i > j ? cout << "*" : cout << " ";
  42. break;
  43. case 1: i < j ? cout << "*" : cout << " ";
  44. break;
  45. case 9: i < dl - j ? cout << "*" : cout << " ";
  46. break;
  47. case 10: dl - i < j ? cout << "*" : cout << " ";
  48. break;
  49. case 3: i <= j && j <= (sh - i)? cout << "*" : cout << " ";
  50. break;
  51. case 4: i >= j && j >= (sh - i)? cout << "*" : cout << " ";
  52. break;
  53. case 7: j <= i && i <= (sh - j) ? cout << "*" : cout << " ";
  54. break;
  55. case 8: j >= i && i >= (sh - j) ? cout << "*" : cout << " ";
  56. break;
  57. case 5: j >= (sh - i) && i >= (sh - j) && j >= i && i >= (sh - j)? cout << "*" : cout << " ";
  58. break;
  59. }
  60. }
  61. }return 0;
  62. }
Add Comment
Please, Sign In to add comment