olekturbo

asd

May 23rd, 2017
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. //Tu wpisać definicję makra PROG:
  5.  
  6.  
  7. #define PROG(typ, typ2) \
  8. for(int i=2;i<ile;i++){ \
  9. typ tab[ile]; \
  10. sscanf(arg[i],"%"#typ2,&tab[i]); \
  11. if(i%2 && tab[i]==0) printf("\nBLAD: dzielenie przez zero"); \
  12. else if(i>2 && i % 2) printf("%"#typ2,tab[i-1]/tab[i]); \
  13. printf(" "); \
  14. }
  15.  
  16.  
  17.  
  18. int main(int ile, char* arg[]) {
  19. if (ile < 2) {
  20. printf("\n POPRAWNE WYWOLANIE:");
  21. printf("\n program typ ciag_danych\n\n");
  22. } else
  23. if (ile%2 == 1) {
  24. printf("\n POPRAWNE WYWOLANIE:");
  25. printf("\n ciag danych musi miec parzysta dlugosc\n\n");
  26. }
  27. else
  28. if (strcmp(arg[1], "int") == 0) PROG(int, i)
  29. else
  30. if (strcmp(arg[1], "double") == 0) PROG(double, lf)
  31. else printf("\n ZNANE TYPY: int, double\n\n");
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment