Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- #include <cstdio>
- #include <ctype.h>
- using namespace std;
- int main(void) {
- char amount = 'C';//переменная для обозначения количества элементов в массиве
- cout << "Enter amount: ";
- amount = getchar();
- cout << amount << endl;
- while(isdigit(amount)) { //iscntrl () - возвращает ненулевое значение если amount - значение это цифра ('0'-'9')
- char *ptr = new char[amount]; //указатель на массив
- cout << "Enter text: ";
- cin.sync(); //очищает потом от имеющихся в нем символов
- cin.getline(ptr, amount);
- int sum = strlen(ptr);
- for (int i = 0; i < sum; i++) {
- cout << ptr[sum - i - 1] << endl;
- }
- delete[] ptr;
- }
- cout << "Error!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement