gashink_t

3. Напишите программу, в которой из функции main() в другую

Feb 11th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define N 5
  4.  
  5.  
  6. void fun(int* b, double* a, int n);
  7. void print_int(int a[]);
  8. void print_double(double a[]);
  9.  
  10. int main()
  11. {
  12.     int new[N];
  13.     double mass[N] = { 1.1, 2.2, 3.3, 4.4, 5.5};
  14.     printf("massiv:\n");
  15.     print_double(mass);
  16.     fun(new, mass, N);
  17.     printf("massiv posle prisvoevanya:\n");
  18.     print_double(mass);
  19.     printf("new mass:\n");
  20.     print_int(new);
  21.  
  22.     return 0;
  23. }
  24.  
  25. void print_int(int a[])
  26. {
  27.     for (int i = 0; i < N; i++) {
  28.         printf("%d ", a[i]);
  29.     }
  30.     printf("\n");
  31. }
  32. void print_double(double a[])
  33. {
  34.     for (int i = 0; i < N; i++) {
  35.         printf("%f ", a[i]);
  36.     }
  37.     printf("\n");
  38. }
  39. void fun(int* b, double* a, int n)
  40. {
  41.     for (int i = 0; i < n; i++) {
  42.         b[i] = (int)a[i];
  43.     }
  44. }
Add Comment
Please, Sign In to add comment