Advertisement
Wojtekd

LAB11

May 19th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <string.h>
  5. #include <assert.h>
  6.  
  7. #define NDEBUG
  8.  
  9. /* zadanie 2*/
  10. char* Literki( const char* wyraz )
  11. {
  12.     char* result = (char*)malloc((strlen(wyraz)+1)*sizeof(char));
  13.     strcpy(result,wyraz);
  14.    
  15.     int i = 0;
  16.     while(result[i] != '\0')
  17.     {
  18.         if(islower(result[i]))
  19.         {
  20.             result[i] = toupper(result[i]);
  21.         }
  22.         else
  23.         {
  24.             result[i] = tolower(result[i]);
  25.         }
  26.         i++;
  27.     }
  28.     return result;
  29. }
  30. /* zadanie 3 */
  31. double sinc( double x)
  32. {
  33.     return x ? sin(x)/x : 1;
  34. }
  35.  
  36. /* zadanie 1 */
  37. void line1( void ) { puts("Pierwsza funkcja konczaca"); }
  38. void line2( void ) { puts("Druga funkcja konczaca"); }
  39.  
  40. int main( int argc, char** argv)
  41. {
  42.     char* napis = Literki("Ala Ma Kota");
  43.     printf("%s\n",napis);
  44.    
  45.    
  46.     /* zadanie 4 */
  47.     int a = atoi(argv[1]);
  48.     assert(a);
  49.     int b = atoi(argv[2]);
  50.     assert(b);
  51.    
  52.     a = abs(a);
  53.     assert(a);
  54.     b = abs(b);
  55.     assert(b);
  56.    
  57.     printf("a:%d  b:%d\n",a,b);
  58.    
  59.     system("pause");
  60.     atexit(line1);
  61.     atexit(line2);
  62.     exit(0);
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement