Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int *tworzenieTablicy(int *t)
  5. {
  6. int wczytane;
  7. int licznik=0;
  8. int rozmiar=10;
  9.  
  10.  
  11. for(int i=0; i<=rozmiar; i++)
  12. {
  13.  
  14. if(licznik==rozmiar)
  15. {
  16.  
  17. rozmiar=licznik+10;
  18. int *nowa= new int[licznik];
  19.  
  20. for(int l=0; l<licznik; l++)
  21. {
  22. nowa[l] = t[l];
  23.  
  24. }
  25. delete [] t;
  26. t= new int[rozmiar];
  27. for(int k=0; k<licznik; k++)
  28. {
  29. t[k]= nowa[k];
  30.  
  31. }
  32.  
  33. i=licznik;
  34. }
  35. cout<<"podaj liczbe: ";
  36. cin>>t[i];
  37. cout<<endl;
  38. if (t[0]<1||t[0]>100)
  39. return NULL;
  40. if (t[i]<1||t[i]>100)
  41. {
  42. for(int j=i; j<rozmiar; j++)
  43. {
  44. t[j]=0;
  45. }
  46. if((licznik)%10==0) {
  47.  
  48. return t+(licznik-1);
  49. }
  50. else
  51. {
  52.  
  53. return t+rozmiar;
  54. }
  55. }
  56.  
  57. licznik++;
  58.  
  59. }
  60.  
  61.  
  62. }
  63.  
  64. int main() {
  65. int *t=new int[10];
  66. cout<<tworzenieTablicy(t);
  67.  
  68.  
  69.  
  70. return 0;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement