Today's Question:  What are you most afraid of as a programmer?        GIVE A SHOUT

How to print "Hello world" 10 times?

In a program, we want to print out "Hello world" 10 times.Some solutions are we can directly write printf("Hello world") 10 times, or we may use a loop to save some typing, or we may use some functions provided by some language libraries. Can you give us your solution to how to print "Hello world" 10 times? You can choose any language, any trick method with your creativity.



#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    vector<string> phrases(10,"Hello world");
    copy(phrases.begin(),phrases.end(),ostream_iterator<string>(cout," "));
    return 0;

  REPLY  Posted by at 2012-09-19 23:55:11


Sorry! You need to login first to post answer.


Login with Facebook Login with Twitter

Back to top