[C++] Problem​ ​A Personal​ ​Message

Now is social media era. In social media, there are many bots that can send message to many people​ ​at​ ​once.​ ​Given​ ​a​ ​person​ ​name,​ ​your​ ​task​ ​is​ ​output​ ​bot​ ​message​ ​in​ ​this​ ​format:

Hi “​PERSONNAME​”, congratulation for learning basic algorithm. We wish you 100% success in this​ ​course!

The first line is the name string. The length of given string is no less than 1 character and no more than 100 character. Each character contains only character ‘A’ – ‘Z’ or ‘a’ – ‘z’ or ‘ ‘ (space) that​ ​indicate​ ​a​ ​person​ ​name.

You need to output a bot message from given name. Please look below for the output format. REMEMBER! If you output unnecessary character(s), the system will give you “Wrong Answer” instead​ ​of​ ​“Correct”.

1st​ ​Sample​ ​Input


Output​ ​for​ ​1st​ ​Sample​ ​Input

Hi​ ​”Andreas”,​ ​congratulation​ ​for​ ​learning​ ​basic​ ​algorithm.​ ​We​ ​wish you​ ​100%​ ​success​ ​in​ ​this​ ​course!


/* Harap diteliti. Barangkali salah
   By Angga Arya S. Jangan dihapus komentar ini
   ya gan wkwkwk xD*/

#include <iostream>
#include <string.h>

using namespace std;

int main() {
    char a[1000];
    int x, trigger = 0;
    cout << "What's your name? : "; cin.getline(a,sizeof(a));
    x = strlen(a);
    for(int i = 0; i < x; i++ ) {
        if(!(a[i] == 32 || (a[i] >= 65 && a[i] <= 90) || (a[i] >= 97 && a[i] <= 122) )) {
            trigger = 1;
    if(trigger == 0) cout << "Hai " << a << ", congratulation for learning basic algorithm\n\n";
    else "Wrong Answer\n\n";

Diskusi Yuk...!

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google

You are commenting using your Google account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s