SHARE
TWEET

c++

a guest Jan 27th, 2020 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <math.h>
  3. #include <ctime>
  4.  
  5. int main(){
  6. srand(time(NULL));
  7. int *tab = new int[25];
  8. int licznik1=0;
  9. int licznik2=0;
  10. bool znaleziono = false;
  11. for(int i=0; i<25; i++){
  12.   tab[i]=(rand()%30)+1;
  13. if(tab[i]%2==0&&tab[i]%3==0){
  14. licznik1++;
  15. }
  16. if(tab[i]>10){
  17.   licznik2++;
  18. }
  19. if(tab[i]==15 && znaleziono==false){
  20.   printf("Pierwszy element tablicy o wartosci 15 to element nr %d \n", i);
  21.   znaleziono = true;
  22. }
  23. else if(i==24&&tab[i]!=15&&znaleziono==false){
  24.   printf("brak\n");
  25. }
  26. }
  27. int *tab2 = new int[25];
  28.   int temp=0;
  29. for(int i=24; i>=0; i--){
  30.   tab2[i]=tab[temp];
  31.   temp+=1;
  32. }
  33. for(int i=0; i<25; i++){
  34.   printf("%d ", tab[i]);
  35.   if(i==24){
  36.     printf("\n");
  37.   }
  38. }
  39. for(int i=0; i<25; i++){
  40.   printf("%d ", tab2[i]);
  41.   if(i==24){
  42.     printf("\n");
  43.   }
  44. }
  45. delete [] tab;
  46. delete [] tab2;
  47.  
  48. int *tab3 = new int[500];
  49. int ile1=0;
  50. int ile2=0;
  51. for(int i=0; i<500; i++){
  52.   tab3[i]=rand()%500+1;
  53. printf("Element tablicy nr %d wynosi %d\n", i, tab3[i]);
  54. if(tab3[i]>99){
  55.   ile1++;
  56. }
  57. if(tab3[i]%100==tab3[i]-floor(tab3[i]/10);){
  58. ile2++;
  59. }
  60. }
  61. return 0;
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top