Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. Zadanie 1.:
  2.  
  3. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  4. //
  5.  
  6. #include "stdafx.h"
  7.  
  8. #include <iostream>
  9. #include <new>
  10.  
  11. int main()
  12. {
  13. int i = 0;
  14. try {
  15.  
  16. for (;;i++) {
  17. int * tablica = new int[100000];
  18. }
  19. }
  20. catch (const std::bad_alloc& e) {
  21. std::cout <<i ;
  22. }
  23.  
  24.  
  25.  
  26. system("pause");
  27. }
  28.  
  29.  
  30. Zadanie 2.:
  31.  
  32. #include "stdafx.h"
  33. #include <iostream>
  34. using namespace std;
  35. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  36. int *tablica;
  37. int length = 0;
  38.  
  39. int main(int argc, char** argv) {
  40.  
  41.  
  42. for (int p=0;; p++)
  43. {
  44. //powyższe może być np. jako zmienne globalne...
  45.  
  46. int *buff = new int[length];
  47. for (int i = 0; i < length; i++)
  48. buff[i] = tablica[i];
  49. tablica = new int[length + 1];
  50. for (int i = 0; i < length; i++)
  51. tablica[i] = buff[i];
  52. //tablica[length]=Edit1->Text;
  53. delete[]buff;
  54. length++;
  55.  
  56. cin >> tablica[p];
  57.  
  58. }
  59.  
  60.  
  61.  
  62. delete[]tablica;
  63.  
  64. system("pause");
  65.  
  66. return 0;
  67. }
  68.  
  69. Zadanie 3.:
  70.  
  71. // ConsoleApplication2.cpp : Defines the entry point for the console application.
  72. //
  73.  
  74. #include "stdafx.h"
  75. #include <iostream>
  76. using namespace std;
  77. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  78.  
  79.  
  80. int main(int argc, char** argv) {
  81. double *tablica1;
  82. double *tablica2;
  83. double *tablica3;
  84. tablica1 = new double[20];
  85. tablica2 = new double[20];
  86. tablica3 = new double[20];
  87. for (int i = 0; i < 20; i++)
  88. {
  89. tablica1[i] = rand();
  90.  
  91. tablica2[i] = rand();
  92.  
  93. tablica3[i] = tablica1[i] * tablica2[i];
  94.  
  95. cout << tablica1[i] << " " << tablica2[i] << " " << tablica3[i] << endl;
  96.  
  97. }
  98.  
  99.  
  100. system("pause");
  101.  
  102. return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement