Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Resti - calcolo
  4.  
  5. *******************************************************************************/
  6. #include <stdio.h>
  7. #define M 300
  8. #define C 210
  9. #define G 10000
  10.  
  11. int main()
  12. {
  13. int m,c;
  14. int err = 2000 ;
  15. int mm,cc;
  16. for (m=5; m<G; m++){
  17. for (c =2; c<G; c++)
  18.  
  19. if (m*M - c*C > 1000){
  20. if (m*M - c*C < err) {
  21. err = m*M - c*C;
  22. mm = m;
  23. cc = c;
  24. }
  25. }
  26. else if (c*C - m*M > 1000){
  27. if (c*C - m*M < err) {
  28. err = c*C - m*M ;
  29. mm = m;
  30. cc = c;
  31. }
  32. }
  33.  
  34.  
  35.  
  36.  
  37. }
  38.  
  39. printf ("MAIALI %d CAPRE %d RES %d \n\n",mm,cc,err);
  40.  
  41.  
  42.  
  43. return 0;
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement