Advertisement
2607

array

Sep 29th, 2021
1,113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. struct vect {
  5.     int x;
  6.     int y;
  7.     int z;
  8. };
  9.  
  10. int main() {
  11.     int n;
  12.     char c;
  13.     if (scanf("%d%c", &n, &c) == 2 && c == '\n') {
  14.         int f = 1;
  15.         int *arr = malloc(n * sizeof(int));
  16.         char s;
  17.         for (int i = 0; i < n; i++) {
  18.             if (scanf("%d%c", arr+i, &s) == 2 && (s == ' ' || s == '\n')) {
  19.                 continue;
  20.             } else {
  21.                 f = 0;
  22.                 printf("n/a");
  23.                 break;
  24.             }
  25.         }
  26.         if (f == 1)
  27.             for (int i = 0; i < n; i++) {
  28.                 printf("%d", *(arr+i));
  29.             }
  30.     } else {
  31.         printf("n/a");
  32.     }
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement