Guest User

godzio.c

a guest
Jan 19th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. /* Funkcja T(n,m) - to nie dziala, bledne polecenie*/
  2.  
  3. #include <stdio.h>
  4.  
  5. unsigned long int T(int n, int m) {
  6.     if (m > 1 || n > 1)
  7.         return T(n-1, m) + 2*T(n, m-1) + 1;
  8.    
  9.     return 1;
  10. }
  11.  
  12.  
  13. int main(void) {
  14.     printf("T(7,7) = %lu\n", T(7,7));
  15.    
  16.     return 0;
  17. }
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. /* Napisy.c */
  28. #include <stdio.h>
  29.  
  30. int ile_malych_a(const char* str) {
  31.     int count = 0;
  32.    
  33.     while (*str)
  34.         if ( *str++ == 'a' ) count++;
  35.    
  36.     return count;
  37. }
  38.  
  39. /* test! */
  40. int main(void) {
  41.     char napis[] = "Mam w sobie tylko dwie litery 'a'.";
  42.     char napis2[] = "A tutaj mamy wiecej liter 'a', zeby sprawdzic,"
  43.                     "czy to dziala.";
  44.     printf("napis  (2): %d\n", ile_malych_a(napis));
  45.     printf("napis2 (6): %d\n", ile_malych_a(napis2));
  46.    
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment