Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. /*
  2. Tipuri de date :
  3.  
  4. [a] simple
  5. ( alg. numere prime , ... )
  6.  
  7. [b] structurate
  8.  
  9. Un tip de date se numeste structurat daca numele lui refera un set de valori
  10.  
  11. 1. masive unidimensionale omogene ( vectori )
  12.  
  13. ---------------------------
  14. V : | | | | |
  15. ---------------------------
  16. 0 1 2 3 .....
  17.  
  18. declarare
  19.  
  20. int V[100];
  21.  
  22.  
  23. referire la elemenet prin operatorul de indexare []
  24.  
  25. V[3]=3254;
  26. cout<<V[3];
  27.  
  28. Aplicatii :
  29.  
  30. A. Algoritmi de ordonare
  31.  
  32. 1. Bubble Sort
  33. --------------
  34. 2. QuickSort
  35. 3. HeapSort
  36.  
  37. */
  38.  
  39. #include<iostream>
  40. #include<stdlib.h>
  41. #include<time.h>
  42. #include<fstream>
  43. using namespace std;
  44.  
  45. int n;
  46. int V[100];
  47.  
  48. int fill_data(int some_array[],int *some_dimension)
  49. { srand(time(0));
  50. *some_dimension = rand()%10;
  51. for ( int i=0;i<*some_dimension;i++) some_array[i] = rand()%1000; return 0;}
  52.  
  53. int print_data(int some_array[],int some_dimension)
  54. {
  55. fstream output("out.dat",ios::out);
  56. output<<endl;
  57. for ( int i=0;i<some_dimension-1;i++) output<<some_array[i]<<" " ;
  58. output<<some_array[some_dimension-1]; output.close();
  59. return 0;}
  60.  
  61.  
  62. int main()
  63. {
  64. fill_data(V,&n);
  65. print_data(V,n);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement