quetzelcoatlus

10b.c

Dec 10th, 2022 (edited)
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. void check(int pixel, int r){
  6.     if(!(pixel%40)) printf("\n");
  7.     pixel = pixel % 40;
  8.     printf("%c", pixel>=r-1 && pixel<=r+1 ? '#' : '.');
  9. }
  10.  
  11. void main(){
  12.     char op[10];
  13.     int d=0;
  14.  
  15.     int pixel=0,regx=1;
  16.     while(scanf("%s %d\n",op,&d) > 0){
  17.         check(pixel,regx);
  18.         if(!strcmp("noop",op)){
  19.             pixel++;
  20.         } else {
  21.             check(++pixel,regx);
  22.             pixel++;
  23.             regx+=d;
  24.         }
  25.     }
  26. }
Tags: adventofcode
Advertisement
Add Comment
Please, Sign In to add comment