Tuesday, July 6, 2021

 Input Format

You are given two strings,  and , separated by a new line. Each string will consist of lower case Latin characters ('a'-'z').

Output Format

In the first line print two space-separated integers, representing the length of  and  respectively.
In the second line print the string produced by concatenating  and  ().
In the third line print two strings separated by a space,  and  and  are the same as  and , respectively, except that their first characters are swapped.

Sample Input

abcd
ef

Sample Output

4 2
abcdef
ebcd af
Answer:
#include <iostream>
#include <string>
using namespace std;
int main() {
    string a,b;
    string temp;
    //input
    cin>>a;
    cin>>b;
    //size
    cout<<a.size()<<" "<<b.size()<<endl;
    //concat
    cout<<(a+b)<<endl;
    //swap
    temp[0]=a[0];
    temp[1]=b[0];
    
    a[0]=temp[1];
    b[0]=temp[0];
    cout<<a<<" "<<b<<endl;
    return 0;
}

Saturday, July 3, 2021

 Given a positive integer , do the following:

  • If , print the lowercase English word corresponding to the number (e.g., one for two for , etc.).
  • If , print Greater than 9.

Input Format

A single integer, .

Constraints

Output Format

If , then print the lowercase English word corresponding to the number (e.g., one for two for , etc.); otherwise, print Greater than 9.

Sample Input 0

5

Sample Output 0

five

Sample Input 2

44

Sample Output 2

Greater than 9
Ans. 
string arr[]={"one","two","three","four","five","six","seven","eight","nine"};
   
    (n>9)?cout<<"Greater than 9":cout<<arr[n-1];

Friday, July 2, 2021

 Input Format

The first line of the input contains ,where  is the number of integers.The next line contains  space-separated integers.

Constraints

, where  is the  integer in the array.

Output Format

Print the  integers of the array in the reverse order, space-separated on a single line.

Sample Input

4
1 4 3 2

Sample Output

2 3 4 1
Answer: 
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    int n;
    int i;
    int a[10000];
    
    cin>>n;
    
    if(n>=1&&n<=1000)
    {
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }   
    }   
    for(i=n-1;i>=0;i--)
        { cout<<a[i]<<" ";}
        
         return 0;
}

Java Regex

You are updating the username policy on your company's internal networking platform. According to the policy, a username is considered v...