C   91
diagonal
Guest on 11th February 2023 01:21:36 PM


  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.     int width, height;
  5.     int i, j;
  6.  
  7.     //printf("#Enter image width:\n");
  8.     scanf("%i", &width);
  9.     //printf("#Enter image height:\n");
  10.     scanf("%i", &height);
  11.  
  12.     printf("P6\n");
  13.     printf("%i %i 255\n", width, height);
  14.    
  15.     for (i = 0; i < height; i++) {
  16.         for (j = 0; j < width - i; j++) {
  17.             printf("%c%c%c", 255, 0, 0);
  18.         }
  19.  
  20.         for (j = 0; j < i; j++) {
  21.             printf("%c%c%c", 0, 255, 0);
  22.         }
  23.     }
  24.    
  25.     return 0;
  26. }

Raw Paste

Login or Register to edit or fork this paste. It's free.