Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include <stdlib.h>
  4. #include <sys/types.h>
  5. #include <sys/stat.h>
  6. #include <fcntl.h>
  7. #include <unistd.h>
  8. void f(int x)
  9. {
  10. if (x & 4) {
  11. printf("r");
  12. } else {
  13. printf("-");
  14. }
  15. if (x & 2) {
  16. printf("w");
  17. } else {
  18. printf("-");
  19. }
  20. if (x & 1) {
  21. printf("x");
  22. } else {
  23. printf("-");
  24. }
  25. }
  26.  
  27. int main(int argc, char **argv)
  28. {
  29. int one;
  30. int two;
  31. int three;
  32. int x;
  33. int i = 0;
  34. for (i = 1 ;i < argc ; i++) {
  35. sscanf(argv[i] , "%о", &x);
  36. one = x / 100;
  37. f(one);
  38. two = (x / 10) % 10;
  39. f(two);
  40. three = x % 10;
  41. f(three);
  42. printf("\n");
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement