Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. P3
  2. 3 2
  3. 255
  4. 255 0 0 0 255 0 0 0 255
  5. 255 255 0 255 255 255 0 0 0
  6.  
  7.  
  8. #include <stdio.h>
  9.  
  10. int main(){
  11. int height;
  12. int width;
  13. int max;
  14. int magicnum;
  15. int count;
  16. unsigned int currentpixel;
  17. unsigned int currentred;
  18. unsigned int currentgreen;
  19. unsigned int currentblue;
  20.  
  21. if(scanf("P%d", magicnum) <= 0){
  22. return 1;
  23. }
  24.  
  25. if(magicnum != 3){
  26. return 1;
  27. }
  28.  
  29. if(scanf("%d%d%d", width, height, size) < 3){
  30. return 1;
  31. }
  32.  
  33. count = 0;
  34. if(count < width*height){
  35. scanf("%d%d%d", currentred, currentgreen, currentblue){
  36. currentpixel = ((currentred*30)+(currentgreen*59)+(currentblue*11) / 100) * 255 / size;
  37. count ++;
  38. printf("%d ", currentpixel);
  39.  
  40.  
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement