Guest User

Untitled

a guest
Feb 21st, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. int vstup;
  2. unsigned long cislo,ofcheck;
  3.  
  4.  
  5.  
  6. //4,294,967,295
  7. //2,147,483,647 4294967295
  8. int input()
  9. {
  10. cislo = 0;
  11. do {
  12.  
  13. vstup=getchar();
  14. inputcheck();
  15. if(vstup != 10){
  16.  
  17. ofcheck==cislo;
  18. overflowcheck();
  19. cislo=cislo * 10 + (vstup - 48);
  20. }
  21. } while (vstup != 10);
  22.  
  23. printf("%lu\n",cislo);
  24. return cislo;
  25. }
  26.  
  27. void inputcheck()
  28. {
  29. if(vstup != 10 && vstup < 48 || vstup > 57)
  30. {
  31. printf("wrong input!");
  32.  
  33. }
  34.  
  35. }
  36.  
  37. void overflowcheck()
  38. {
  39.  
  40. if((cislo - (vstup - 48)) / 10 != ofcheck)
  41. {printf("overflow");}
  42. }
Add Comment
Please, Sign In to add comment