Xiao Nai He
Xiao Nai He

Reputation: 3

Creating serial text output with a text

Hello I want to know how can I make a code like i want to input a number XXX it will output

ChinaXXX BeijingXXX-CHINA-XXX +180243189(XXX)

Like this. Advance thanks Sorry for the title. I dont how can i said about on title.

Upvotes: 0

Views: 33

Answers (2)

Pepijn Kramer
Pepijn Kramer

Reputation: 13076

Or if you have C++20 available, use std::format

#include <format>
#include <iostream>
#include <string>

int main()
{
    std::string number;
    std::cin >> number;
    std::cout << std::format("China{0} Beijing{0}-CHINA-{0} +180243189({0})\n", number);
    return 0;
}

Upvotes: 1

user3188445
user3188445

Reputation: 4774

#include <iostream>
#include <string>

int
main()
{
  std::string number;
  std::cin >> number;
  std::cout << "China" << number << " Beijing" << number
        << "-CHINA-" << number << " +180243189(" << number << ")"
        << std::endl;
}

Upvotes: 3

Related Questions