Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "time.h"
  3. #define K 200
  4.  
  5. int MY_FUNC(int *, int *);
  6.  
  7. int main ()
  8. {
  9. int mass_ch[K], new_ch[K];
  10. MY_FUNC(mass_ch, new_ch);
  11. return 0;
  12. }
  13.  
  14. int MY_FUNC(int *mass_ch, int *new_ch)
  15. {
  16. int k, kst;
  17. srand (time(NULL));
  18. printf ("\tVvedit bajany rozmirnist' masuvy: \n");
  19. scanf("%d", &kst);
  20. printf ("\n \t Vash masyv:");
  21. for (k=0; k<kst; k++)
  22. {
  23. mass_ch[k]= rand()%1000+1;
  24. printf ("\n%d) %d", k+1, mass_ch[k]);
  25. int poriadok = 1;
  26. int ch;
  27. new_ch[k]=0;
  28. while (mass_ch[k]>0)
  29. {
  30. ch = mass_ch[k] % 10;
  31. if (ch & 1 == 1 && ch!=9)
  32. ch=ch+1;
  33. if (ch == 9)
  34. ch = 0;
  35. mass_ch[k] /= 10;
  36. new_ch[k] += ch * poriadok;
  37. poriadok = poriadok * 10;
  38. }
  39. }
  40. printf ("\n \t Novyi masyv:");
  41. int j;
  42. for (j=0; j < kst; j++)
  43. printf ("\n%d) %d", j+1, new_ch[j]);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement