Skip to content

Instantly share code, notes, and snippets.

@steveburkett
Last active October 28, 2019 16:31
Show Gist options
  • Save steveburkett/4583542 to your computer and use it in GitHub Desktop.
Save steveburkett/4583542 to your computer and use it in GitHub Desktop.
Given an input N, print 'hello world' N times.
#include <iostream>
using namespace std;
int main() {
int i, n;
cin >> n;
for (i=0; i<n; i++) {
cout << "hello world\n";
}
return 0;
}
using System;
namespace Solution {
class Solution {
static void Main(string[] args) {
var line1 = System.Console.ReadLine().Trim();
var N = Int32.Parse(line1);
for (var i = 0; i < N; i++) {
System.Console.WriteLine("hello world");
}
}
}
}
import java.io.*;
public class Solution {
public static void main(String args[] ) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line = br.readLine();
int N = Integer.parseInt(line);
for (int i = 0; i < N; i++) {
System.out.println("hello world");
}
}
}
N = int(raw_input())
for i in xrange(N):
print "hello world"
gets.to_i.times { puts "hello world" }
(setq strN (read-line))
(setq N (parse-integer strN))
(loop for i from 1 to N do
(write "hello world")
(terpri)
)
@Nditah
Copy link

Nditah commented Mar 20, 2018

Given an input N, print 'hello world' N times couldn't get any better with php

echo str_repeat('hello world' N);

@swachchand
Copy link

inpt = int(input ("Enter Number: "))

for i in range(inpt):
print("hello world")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment