Guest User

Untitled

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