Advertisement
Guest User

Untitled

a guest
Feb 18th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #pragma argsused
  2. double Faktorial(int);
  3. double Faktorial_R(int);
  4.  
  5.  
  6. int a[100], i, n;
  7. randomize();
  8. // do{
  9. cout << "\nVvedite n(<=100)";
  10. cin >> n;
  11. //if (n<1||n>100) printf("Ne verno ykazan razmer maccuva");
  12. //}while(n<1||n>100);
  13.  
  14. int function;
  15. do{
  16. cout << "Choose 1-enter 2-random ";
  17. cin >> function;
  18. switch (function) {
  19.  
  20. case 1:
  21. cout << "\n Enter the array";
  22. for (i = 0; i < n; i++)
  23. cin >> &a[i];
  24. break;
  25.  
  26.  
  27. case 2:
  28. for (i = 0; i < n; i++)
  29. {a[i] = random(21)-10;
  30. cout << setw(5) << a[i];}
  31. break;
  32.  
  33. default: cout << "\n Ne vibran sposob vvoda";
  34. }
  35. } while ((function<1)||(function>2));
  36.  
  37.  
  38. int main(int)
  39. {
  40. int n, kod;
  41. while(true) {
  42. cout << "\n Recurs - 0\n Simple - 1\n Else - Exit\t";
  43. cin >> kod;
  44. if (kod <0 || kod > 1) return;
  45. cout << "\tInput n " ;
  46. cin >> n;
  47. switch(kod) {
  48. case 0:
  49. cout << "\tRecurs = " << Faktorial_R(a[i]) << endl;
  50. break;
  51. case 1:
  52. cout << "\tSimple = " << Faktorial(a[i]) << endl;
  53. break;
  54. }
  55. }
  56. }
  57.  
  58. puts("\n Press any key ... ");
  59. getch();
  60. return 0;
  61. }
  62.  
  63. int Faktorial(int a[i]){
  64. for (i<0;i<n;i++){
  65. if (a[i]!=1 && a[i+1]=1 || a[i-1]=1) a[i]=0;
  66. return a[i];
  67. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement