Advertisement
j0h

RangeMod

j0h
Sep 9th, 2023
1,146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. //logic to scale colours based on range
  4. int main() {
  5. int minD=99;
  6. int maxD=2000;
  7. unsigned int range= abs(maxD-minD);
  8. printf("Range: %d\n", range );
  9. //
  10. int result = range / 7;
  11. int remainder = result % 7;
  12. int spectrum = result - remainder;
  13.  printf("spectrum: %d\n",spectrum);
  14. int depth_value=20;
  15. if(depth_value>minD &&depth_value<maxD){    //if depth_value in range
  16.     printf("Value in Range:\n");
  17.  if(depth_value>=spectrum*1 && depth_value<=spectrum*2){printf("Red %d\n",depth_value);}
  18. else if(depth_value>=spectrum*2 && depth_value<=spectrum*3){printf("Oragnge %d\n",depth_value);}
  19. else if(depth_value>=spectrum*3 && depth_value<=spectrum*4){printf("yellow\n %d",depth_value);}
  20. else if(depth_value>=spectrum*4 && depth_value<=spectrum*5){printf("Green\n %d",depth_value);}
  21. else if(depth_value>=spectrum*5 && depth_value<=spectrum*6){printf("blue %d\n",depth_value);}
  22. else if(depth_value>=spectrum*6 && depth_value<=spectrum*7){printf("fuchia %d\n",depth_value);}
  23. else if(depth_value>=spectrum*7 && depth_value<=spectrum*8){printf("violet %d\n",depth_value);}
  24. }else {
  25.     if(depth_value<minD || depth_value>maxD){printf("balck %d\n",depth_value);}
  26. }
  27.  
  28. /*
  29. for (int i=minD; i<=maxD; i++){
  30.  
  31.     // Calculate the remainder when dividing N by 7
  32.     int remainder = i % 7;
  33.     // Subtract the remainder from N to make it evenly divisible by 7
  34.     int result = i - remainder;
  35.     printf(" %d divided by 7 remains:%d divisible by: %d\n",i,remainder, result);
  36.     }
  37. */
  38.     return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement