Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- double find_mod(double a, double b){
- if(a < 0) a = -a;
- if(b < 0) b = -b;
- double mod = a;
- while(mod >= b){
- mod = mod - b;
- }
- if(a < 0){
- mod = -mod;
- }
- return mod;
- }
- int main(){
- int t; cin >> t;
- while(t--){
- double a, b;
- cin >> a >> b;
- cout << find_mod(a, b) << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment