Advertisement
ohad

Untitled

Oct 13th, 2016
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. #include <stdio.h>
  2. #define N 2
  3. char Add_To_Mat(int aa[], char** ptr1)
  4. {
  5.     char *c;
  6.     char *s;
  7.     char max = '\0';
  8.     for (int i = 0; i < N*N; i++)
  9.     {
  10.         printf("Enter string: ");
  11.         scanf_s("%s", &s);
  12.         *(ptr1 + i) = s;
  13.     }
  14.     for (int i = 0; i < N*N; i++)
  15.     {
  16.         int j = 0;
  17.         c = *(ptr1 + i);
  18.         while (*(c + j) != '\0')
  19.         {
  20.             aa[*(c + j)]++;
  21.             (aa[*(c + j)] > aa[max]) ? (max = *(c + j)) : 0;
  22.             j++;
  23.         }
  24.     }
  25.     return max;
  26. }
  27. void main(void)
  28. {
  29.     int ascii_array[128] = { 0 };
  30.     char* mat[N][N];
  31.     char **ptr1 = &(mat[0][0]);
  32.     char maxc = Add_To_Mat(ascii_array, ptr1);
  33.     printf("%c:%d", maxc, ascii_array[maxc]);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement