Created
August 26, 2014 17:09
-
-
Save kolodziej/0736e324bf1ca0a3c81f to your computer and use it in GitHub Desktop.
Obliczanie silni z obsługą parametrów linii poleceń
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> | |
using namespace std; | |
int main(int argc, char ** argv) | |
{ | |
int n = 0; | |
int silnia = 1; | |
cout << "\tObliczanie silni" << endl; | |
if (argc >= 2) | |
{ | |
n = atoi(argv[1]); | |
} else { | |
cout << "Podaj liczbe z jakiej mam policzyc silnie: "; | |
cin >> n; | |
} | |
for (int i = 1; i <= n; silnia *= i++); | |
cout << "n! = " << n << "! = " << silnia << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment