Better Passwords | Toph problem solutions

 Byang is creating an account on Toph. He needs your help to create a strong password.

Byang will give you a word, and you will need to make the following changes to the word to make it a stronger password:

  • Make the first character an uppercase
  • Replace all s with $
  • Replace all i with !
  • Replace all o with ()
  • Append a . (period) at the end of the password

Input

The input will contain a string A (0 < \texttt{Length of A} < 16). A will contain lowercase alphabets only.

Output

Print the better password after applying all the necessary changes to the original word A.

Sample

InputOutput
unsophisticated
Un$()ph!$t!cated



#include<iostream>
#include<string>
using namespace std;

int main()
{

    string pass;
    int a;
    cin>>pass;
    pass[0]=toupper(pass[0]);
    a=pass.length();
   for(int i=1;i<=a;i++){
   if(pass[i]=='s' || pass[i]=='S'){
    pass[i]='$';
    }
    if(pass[i]=='i' || pass[i]=='I'){
    pass[i]='!';
    }
    if(pass[i]=='o' || pass[i]=='O'){
    //pass[i]=" ";
    pass.replace(i,1,"()");
    
   // pass.insert (i,"()");
    //pass[i]='()';
    }

   }
    //pass.insert (a+1,".");
    
    
    cout<<pass<<".";
    
    return 0;
}







Post a Comment

0 Comments