[ create a new paste ] login | about

Link: http://codepad.org/Nw2Cb7Ji    [ raw code | output | fork ]

C++, pasted on May 4:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*剰余を返すプログラム*/

#include <iostream>
#include <math.h>
using namespace std;

int main(){
	double A = 5.3, B = 0.1;

	//cin >> A >> B; //Codepadなためコメントアウト 初期化の際に値を与える。
	
	cout << fmod(A,B) << " [fmodを使った場合]" << endl;
	
	while(A >= B){
		A -= B;
	}
	
	cout << A << " [独自方式を取った場合]" << endl;
}


Output:
1
2
0.1 [fmodを使った場合]
-4.71845e-16 [独自方式を取った場合]


Create a new paste based on this one


Comments: