Skip to content

Instantly share code, notes, and snippets.

@cypres
Created November 13, 2011 10:45
Show Gist options
  • Save cypres/1361976 to your computer and use it in GitHub Desktop.
Save cypres/1361976 to your computer and use it in GitHub Desktop.
hoppity hop
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main(int argc, char** argv) {
if (argc != 2) {
cout << "Wrong number of arguments: " << argc << endl;
return 1;
}
int l=atoi(argv[1]);
if (l == 0) {
cout << "Unknown integer: " << argv[1] << endl;
return 1;
}
for(int i=1; i<=l; i++) {
if (i%5==0 && i%3==0) cout << "Hop" << endl;
else if (i%5==0) cout << "Hophop" << endl;
else if (i%3==0) cout << "Hoppity" << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment