fork download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.  
  9. cout << "------------------------------------------" << endl;
  10. cout << "\tЧисло\t\tРешение" << endl;
  11. cout << "------------------------------------------" << endl;
  12. for (double i = -4.0; i <= 4.0; i += 0.1) {
  13. cout << "\t" << i << "\t\t" << abs(i - 2.0) + abs(i + 1.0) << endl;
  14. }
  15. cout << "------------------------------------------" << endl;
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0.01s 5456KB
stdin
Standard input is empty
stdout
------------------------------------------
	Число		Решение
------------------------------------------
	-4		9
	-3.9		8.8
	-3.8		8.6
	-3.7		8.4
	-3.6		8.2
	-3.5		8
	-3.4		7.8
	-3.3		7.6
	-3.2		7.4
	-3.1		7.2
	-3		7
	-2.9		6.8
	-2.8		6.6
	-2.7		6.4
	-2.6		6.2
	-2.5		6
	-2.4		5.8
	-2.3		5.6
	-2.2		5.4
	-2.1		5.2
	-2		5
	-1.9		4.8
	-1.8		4.6
	-1.7		4.4
	-1.6		4.2
	-1.5		4
	-1.4		3.8
	-1.3		3.6
	-1.2		3.4
	-1.1		3.2
	-1		3
	-0.9		3
	-0.8		3
	-0.7		3
	-0.6		3
	-0.5		3
	-0.4		3
	-0.3		3
	-0.2		3
	-0.1		3
	2.41474e-15		3
	0.1		3
	0.2		3
	0.3		3
	0.4		3
	0.5		3
	0.6		3
	0.7		3
	0.8		3
	0.9		3
	1		3
	1.1		3
	1.2		3
	1.3		3
	1.4		3
	1.5		3
	1.6		3
	1.7		3
	1.8		3
	1.9		3
	2		3
	2.1		3.2
	2.2		3.4
	2.3		3.6
	2.4		3.8
	2.5		4
	2.6		4.2
	2.7		4.4
	2.8		4.6
	2.9		4.8
	3		5
	3.1		5.2
	3.2		5.4
	3.3		5.6
	3.4		5.8
	3.5		6
	3.6		6.2
	3.7		6.4
	3.8		6.6
	3.9		6.8
------------------------------------------