Advertisement
zsoltizbekk

orai

May 6th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void *utolsooszlop(int t[], int sor, int oszlop)
  6. {
  7.     int *uj=(int *)calloc(sor, sizeof(int));
  8.     int i;
  9.  
  10.     for (i=0; i<sor; i++)
  11.         uj[i]=t[i*oszlop+oszlop-1];
  12.  
  13.     return uj;
  14. }
  15.  
  16. int main()
  17. {
  18.     char *m[3][4]={{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
  19.     int i, j;
  20.     int *utolso;
  21.     utolso=utolsooszlop(&m[0][0], 3, 4);
  22.  
  23.     for (i=0; i<3; i++)
  24.         printf("%d\n", utolso[i]);
  25.     return EXIT_SUCCESS;
  26. }
  27.  
  28. /*
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <string.h>
  32.  
  33. void kiir(int *t, int sor, int oszlop)
  34. {
  35.     int i, j;
  36.     for (i=0; i<sor; i++){
  37.         for (j=0; j<oszlop; j++){
  38.             putchar(' ');
  39.         printf("%d", t[i*oszlop+j]);
  40.         }
  41.     }
  42. }
  43.  
  44. int main()
  45. {
  46.     char *m[3][4]={{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
  47.     int i, j;
  48.     kiir(m, 3, 4);
  49.     return EXIT_SUCCESS;
  50. }
  51. */
  52. /*
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #include <string.h>
  56.  
  57. int main()
  58. {
  59.     char *m[3][4]={"januar", "februar", "marcius", "aprilis", "majus", "junius", "julius", "augusztus", "szeptember", "oktober", "november", "december"};
  60.     int i, j;
  61.  
  62.     printf("%d, %d\n", sizeof(m), sizeof(char *));
  63.     printf("%p (%u)\n", m, m);
  64.     printf("%p (%u)\n", m+1, m+1);
  65.  
  66.     for (i=0; i<3; i++){
  67.         for (j=0; j<4; j++){
  68.             if (j>0)
  69.                 putchar(' ');
  70.             printf("%s", m[i][j]);
  71.         }
  72.         putchar('\n');
  73.     }
  74.     return EXIT_SUCCESS;
  75. }
  76. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement