"Create a program that allows to type a old password then it should creates a new password. All vowel letter should Replace with letter X and all numbers should replace with letter Z. New password must be done in reversed".
I have a code of this but I dont know how to reverse.
#include<iostream>
#include<string>
using namespace std;
int main()
{
long loop = 0;
int k = 0;
int count = 0;
while (loop>-1)
{
string input;
cout << "Enter Original Password (Enter -1 to end): ";
getline(cin, input);
if (input == "-1")
{
break;
}
count = input.length();
Enter Original Password (Enter -1 to end): A1 qw2
Your New Password: Zwq ZX
Enter Original Password (Enter -1 to end): aap2
Your New Password: ZpXX
Enter Original Password (Enter -1 to end): -1
Press any key to continue...
#include <iostream>
#include <string>
#include <cctype> // std::isdigit
#include <algorithm> // std::reverse
int main()
{
const std::string vowels = "AEIOUaeiou" ;
std::string original_pword ;
while( std::cout << "Enter Original Password (Enter -1 to end): " &&
std::getline( std::cin, original_pword ) && original_pword != "-1" )
{
std::string new_pword ;
// http://www.stroustrup.com/C++11FAQ.html#forfor( char c : original_pword ) // for each char in the original password
{
// if it is a vowel (if it is a character in the vowels string), add an 'X'
// https://en.cppreference.com/w/cpp/string/basic_string/findif( vowels.find(c) != std::string::npos ) new_pword += 'X' ;
// otherwise, if it is a digit, add a 'Z'
// https://en.cppreference.com/w/cpp/string/byte/isdigitelseif( std::isdigit(c) ) new_pword += 'Z' ;
// otherwise, add the character as it is
else new_pword += c ;
}
// reverse the new password https://en.cppreference.com/w/cpp/algorithm/reverse
std::reverse( new_pword.begin(), new_pword.end() ) ;
std::cout << "your new password is: '" << new_pword << "'\n" ;
}
}