Advertisement
mailnesia

cOpal

May 5th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.23 KB | None | 0 0
  1. #include <stdio.h>
  2. #define W 3
  3. #define K 9
  4. main(){
  5.     char t[W][K] = {
  6.         {'B', 'a', 'l', 't', 'y', 'c', 'k', 'i'},
  7.         {'F','e','s','t','i','w','a','l'},
  8.         {'N','a','u','k','i'}
  9.     };
  10.     int i;
  11.     for(i = 0 ; i < W ; i++ )
  12.         printf("%s ", t[i] );
  13. }
  14.  
  15.  
  16.  
  17.  
  18. #include <stdio.h>
  19. #define N 10
  20. main(){
  21.     char t[N];
  22.  
  23.     fgets(t,N,stdin);
  24.     puts("Podany lancuch to:");
  25.     puts(t);
  26. }
  27.  
  28.  
  29.  
  30.  
  31.  
  32. #include <stdio.h>
  33. #define N 500
  34. // wciśnięcie przez uytkownika na początku linii kombinacji Ctrl-Z powinno wysłać EOF do programu i zakończyć pobieranie danych
  35. main(){
  36.     int i;
  37.     char t[N];
  38.     i = 0;
  39.     do {
  40.         t[i] = getchar();
  41.         i++;
  42.     }while( t[i-1] != EOF && i<N );
  43.     t[i-1] = '\0';
  44.     printf("Podany lancuch znakow to: _%s_", t);
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. #include <stdio.h>
  53. #define N 5
  54. main(){
  55.     int c, i;
  56.     char t[N];
  57.     i = 0;
  58.     do {
  59.         c=getchar();
  60.         if( EOF == c || N-1 == i )
  61.             t[i] = '\0';
  62.         else
  63.             t[i] = c;
  64.         i++;
  65.     }while( EOF != c && i<N );
  66.     printf("Podany lancuch znakow to: _%s_", t);
  67. }
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. #include <stdio.h>
  77. //program powinien wydrukowac wprowadzony znak
  78. main(){
  79.     char c;
  80.  
  81.     puts("Podaj jeden znak:");
  82.     c = getchar();
  83.     puts("Podany znak to:");
  84.     c = putchar(c);
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95. #include <stdio.h>
  96. #define W 3
  97. #define K 9
  98. main(){
  99.     char t[W][K] = {
  100.         {'B', 'a', 'l', 't', 'y', 'c', 'k', 'i'},
  101.         {'F','e','s','t','i','w','a','l'},
  102.         {'N','a','u','k','i'}
  103.     };
  104.     int i,w;
  105.     for(w = 0 ; w < W ; w++ ) {
  106.         i = 0;
  107.         do {
  108.             putchar( t[w][i] );
  109.             i++;
  110.         }while( '\0' != 0);
  111.         putchar(' ');
  112.     }
  113. }
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124. #include <stdio.h>
  125. #define N 2
  126. // uzupelnij tylko miejsce oznaczone <???>. Nie modyfkuj zadnych innych czesci kodu.
  127. // ponizszy program powinien wydrukowac tylko 1 i 3 znak podany na stdin.
  128. // np, jesli na stdin trafi: abc[ENTER], program powinien wydrukowac ac
  129. main(){
  130.     char c;
  131.     int i;
  132.     for(i = 0; i < N ; i++ ) {
  133.         c = getchar();
  134.         putchar(c);
  135.         while(i<N){
  136.             c = getchar();
  137.             i++;
  138.         }
  139.         putchar(c);
  140.     }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement