wojiaocbj

E4 D bitop

Apr 5th, 2022
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. /*
  2.  Author: Cao Beijian
  3.  Result: AC Submission_id: 4278576
  4.  Created at: Tue Apr 05 2022 21:37:20 GMT+0800 (China Standard Time)
  5.  Problem_id: 5477   Time: 4 Memory: 1616
  6. */
  7.  
  8. #include <stdio.h>
  9. int main(){
  10.     int n = 0, a, i, a03, j;
  11.     scanf("%d", &a);
  12.     a03 = a & 7;
  13.     while(a){
  14.         a >>= 3;
  15.         n++;
  16.     }
  17.     for(i = 2; i >= 0; i--){
  18.         if(a03 & (1 << i)){
  19.             for(j = 0; j < 3 * n; j++){
  20.                 putchar('-');
  21.             }
  22.         }
  23.         else{
  24.             for(j = 0; j < n; j++){
  25.                 putchar('-');
  26.             }
  27.             for(j = 0; j < n; j++){
  28.                 putchar(' ');
  29.             }
  30.             for(j = 0; j < n; j++){
  31.                 putchar('-');
  32.             }
  33.         }
  34.         putchar('\n');
  35.     }
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment