2

I love Zaoly!!! — Tutorial (English)

 1 year ago
source link: https://codeforces.com/blog/entry/115361
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Problem Link: Zaoly Contest - A - I love Zaoly!!!

This problem is easy, whose general idea is:

  • Read an integer $$$T$$$.
  • Read integer $$$n$$$ for $$$T$$$ times in a row.
  • For each integer $$$n$$$ read, print I love Zaoly first, and then print exclamation point ! for $$$n$$$ times using loop. At last, print a newline character.

Note that there is no space between I love Zaoly and exclamation points.

Note that you need to add a newline character after printing each case, otherwise all the output will be on one line.

Here is a C++ solution:

#include <iostream>

using namespace std;

int main()
{
    int t = 0;
    cin >> t;
    while (t > 0)
    {
        int n = 0;
        cin >> n;
        cout << "I love Zaoly";
        while (n > 0)
        {
            cout.put('!');
            --n;
        }
        cout.put('\n');
        --t;
    }
    return 0;
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK