Guest User

Untitled

a guest
Nov 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6. using namespace std;
  7. void draw_the_thing();
  8. char *thing[2] = {"cube", "shar"};
  9. char *color[4] = {"green","orange","red","blue"};
  10. int rand_num(int n);
  11.  
  12. int main() {
  13.  
  14. int n,i;
  15.  
  16. srand(time(NULL));
  17.  
  18. while (1) {
  19. cout << "enter number:" << " ";
  20. cin >> n;
  21. for (i=1; i <= n; i++)
  22. draw_the_thing();
  23.  
  24. }
  25. getch();
  26. return 0;
  27. }
  28. void draw_the_thing() {
  29.  
  30. int r;
  31. int s;
  32.  
  33. r = rand_num(2);
  34. s = rand_num(4);
  35.  
  36. cout << thing[r] << " " << color[s] << endl;
  37.  
  38. }
  39.  
  40.  
  41. int rand_num(int n) {
  42. return rand() % n;
  43. }
Add Comment
Please, Sign In to add comment