본문 바로가기
코드/C++

how can Balmer find

by bongin 2023. 8. 17.
728x90
반응형
#include <iostream>
#include <string>
#include <math.h>
#include <cmath>

void main()
{
	float a = 0;
	float b = 0;
	float c = 0;
	float d = 0;
	float t = 0;

	for (float i =1; i<30; i++)
	{
		for (float j =1; j<30; j++)
		{
			/*
				a = round(656.210 / ( i / j ) * 1000) / 1000;
				/(i/j)를 인식하지 못해 /i*j로 변경

				Exp		Formula
				656.210		656.208 = 364.560 * 9 / 5
				486.074		486.080 = 364.560 * 16 / 12 (= 4 / 3)
				434.010		434.000 = 364.560 * 25 / 21
				410.120		410.130 = 364.560 * 36 / 32 (= 9 / 8)
			*/

			a = round(656.210 / i * j  * 1000) / 1000;
			b = round(486.074 / a * 1000) / 1000;

			for (float k =1; k<30; k++)
			{
				for (float l =1; l<30; l++)
				{
					t = round(k / l * 1000) / 1000;
					if (abs(b-t) <= 0.001)
					{
						/*
							std::cout << "656.210 / " << i << " * " << j << " = " << a << ", "
							<<"486.074 / " << a << " = " << b << ", "
							<< k << " / " << l << " = " << round(k / l * 10000) / 10000 << std:: endl;
						*/
						c = round(434.010 / a * 1000) / 1000;
						for (float m =1; m<30; m++)
						{
							for (float n =1; n<30; n++)
							{
								t = round(m / n * 1000) / 1000;
								if (abs(c-t) <= 0.001)
								{
									d = round(410.120 / a * 1000) / 1000;
									for (float o =1; o<30; o++)
									{
										for (float p =1; p<30; p++)
										{
											t = round(o / p * 1000) / 1000;
											if (abs(d-t) <= 0.001)
											{
												std::cout << "i = " << i << ", "
												<< "j = " << j << ", "
												<< "a = " << a << ", "

												<< "k = " << k << ", "
												<< "l = " << l << ", "
												<< "b = " << b << ", "

												<< "m = " << m << ", "
												<< "n = " << n << ", "
												<< "c = " << c << ", "

												<< "o = " << o << ", "
												<< "p = " << p << ", "
												<< "d = " << d << std::endl;
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}
728x90
반응형

'코드 > C++' 카테고리의 다른 글

참조자를 반환하는 함수  (0) 2023.09.19
What does the GL_ARRAY_BUFFER target mean in glBindBuffer?  (0) 2023.08.31
Texture.cpp  (1) 2023.07.29
OpenGL 환경설정  (0) 2023.07.24
서브시스템  (0) 2023.07.09

댓글