Created
December 1, 2014 13:20
-
-
Save stefanolafs/5a59323db62a5c0f99c0 to your computer and use it in GitHub Desktop.
Megaflott C++ jólatré með eða án stjörnu! How cool can you get?!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
#include <cctype> | |
using namespace std; | |
void with_star(int n); | |
void no_star(int n); | |
int main() | |
{ | |
cout << "\n***********************************************" << endl; | |
cout << "Thetta forrit teiknar jolatre med eda an stjornu\n"; | |
cout << "af theirri staerd sem thu velur :D" << endl; | |
cout << "***********************************************" << endl; | |
bool more = true; | |
do | |
{ | |
int n; | |
char choose; | |
cout << "\nViltu" << endl; | |
cout << "A. Med stjornu eda" << endl; | |
cout << "B. An stjornu" << endl; | |
cin >> choose; | |
choose = static_cast<char>(toupper(choose)); | |
switch (choose) | |
{ | |
case 'A': with_star(n); | |
break; | |
case 'B': no_star(n); | |
break; | |
default: cout << "OOPS! Thu valdir hvorki A ne B.\n"; | |
exit(1); | |
} | |
char again; | |
cout << "\nViltu teikna annad tre? (j/n): "; | |
cin >> again; | |
if (again == 'n' || again == 'N') | |
{ | |
more = false; | |
} | |
}while (more == true); | |
cout << "\nGledileg jol!\n\n"; | |
return 0; | |
} | |
void with_star(int n) | |
{ | |
cout << "\nVeldu staerd jolatres (minnst 4, flottast i 8+): "; | |
cin >> n; | |
n += 1; | |
cout << endl; | |
if (n<4) | |
{ | |
cout << "OOPS! Thu valdir tolu sem er laegri en 4" << endl; | |
exit(1); | |
} | |
for (int i=0; i<(n-4); i++) | |
cout << ' '; | |
cout << "__/\\__" << endl; | |
for (int i=0; i<(n-4); i++) | |
cout << ' '; | |
cout << "\\ /" << endl; | |
for (int i=0; i<(n-4); i++) | |
cout << ' '; | |
cout << "/_ _\\" << endl; | |
for (int i=0; i<(n-4); i++) | |
cout << ' '; | |
cout << " \\/"; | |
// línur | |
for (int i = 0; i < n; i++) | |
{ | |
// bil | |
for (int k = n; k > i+1; k--) | |
{ | |
cout << ' '; | |
} | |
// 'hattar' og skraut | |
if (i%2==0 && i>=2) | |
{ | |
for (int j = 0; j < i/2; j++) | |
{ | |
cout << '^' << '^' << '@' << '^'; | |
} | |
} | |
else | |
{ | |
if (i>2) | |
{ | |
cout << '0'; | |
for (int j = 0; j < (i*2)-2; j++) | |
{ | |
cout << '^'; | |
} | |
cout << '0'; | |
} | |
else | |
{ | |
for (int j = 0; j < i*2; j++) | |
{ | |
cout << '^'; | |
} | |
} | |
} | |
cout << endl; | |
} | |
// fótur | |
for (int i=0; i<(n-3); i++) | |
cout << ' '; | |
cout << "|__|" << endl; | |
} | |
void no_star(int n) | |
{ | |
cout << "\nVeldu staerd jolatres (minnst 3): "; | |
cin >> n; | |
cout << endl; | |
n += 1; | |
if (n<3) | |
{ | |
cout << "OOPS! Thu valdir tolu sem er laegri en 3" << endl; | |
exit(1); | |
} | |
// línur | |
for (int i = 0; i < n; i++) | |
{ | |
// bil | |
for (int k = n; k > i+1; k--) | |
{ | |
cout << ' '; | |
} | |
// 'hattar' og skraut | |
if (i%2==0 && i>=2) | |
{ | |
for (int j = 0; j < i-1; j++) | |
{ | |
cout << '^' << '@'; | |
} | |
cout << '^'; | |
} | |
else | |
{ | |
if (i>2) | |
{ | |
cout << '0'; | |
for (int j = 0; j < (i*2)-3; j++) | |
{ | |
cout << '^'; | |
} | |
cout << '0'; | |
} | |
else | |
{ | |
for (int j = 0; j < i*2-1; j++) | |
{ | |
cout << '^'; | |
} | |
} | |
} | |
cout << endl; | |
} | |
// fótur | |
for (int i=0; i<(n-3); i++) | |
cout << ' '; | |
cout << "|_|" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment