Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma argsused
- double Faktorial(int);
- double Faktorial_R(int);
- int a[100], i, n;
- randomize();
- // do{
- cout << "\nVvedite n(<=100)";
- cin >> n;
- //if (n<1||n>100) printf("Ne verno ykazan razmer maccuva");
- //}while(n<1||n>100);
- int function;
- do{
- cout << "Choose 1-enter 2-random ";
- cin >> function;
- switch (function) {
- case 1:
- cout << "\n Enter the array";
- for (i = 0; i < n; i++)
- cin >> &a[i];
- break;
- case 2:
- for (i = 0; i < n; i++)
- {a[i] = random(21)-10;
- cout << setw(5) << a[i];}
- break;
- default: cout << "\n Ne vibran sposob vvoda";
- }
- } while ((function<1)||(function>2));
- int main(int)
- {
- int n, kod;
- while(true) {
- cout << "\n Recurs - 0\n Simple - 1\n Else - Exit\t";
- cin >> kod;
- if (kod <0 || kod > 1) return;
- cout << "\tInput n " ;
- cin >> n;
- switch(kod) {
- case 0:
- cout << "\tRecurs = " << Faktorial_R(a[i]) << endl;
- break;
- case 1:
- cout << "\tSimple = " << Faktorial(a[i]) << endl;
- break;
- }
- }
- }
- puts("\n Press any key ... ");
- getch();
- return 0;
- }
- int Faktorial(int a[i]){
- for (i<0;i<n;i++){
- if (a[i]!=1 && a[i+1]=1 || a[i-1]=1) a[i]=0;
- return a[i];
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement