/*
This is a simple program to calculate Hydrogen spectrum
Readers are sugguest to read related books to understand the theory.
Author: Muguangde 07/21/2014-15:10
*/
#include<iostream>
#define R 109667.581
using namespace std;
void func(int i)
{
int n2 = 0, n3 = 0;//seting n3 here to limit first 10 spectrum lines
n2 = i + 1;
n3 = i + 11;
for (n2 ; n2 <n3; n2++)
{
cout << "n1= " << i << " n2= " << n2 << endl;
cout <<"Wavelength(nm)= "<<1e7 / (R*double((1.0 / (i*i)) - (1.0 / (n2*n2))))<<endl;
}
}
int main()
{
int n1 = 0;
for (n1 = 1; n1 <7; n1++)
{
func(n1);//calling function func to calculate wavelength, n1 from 1 to 6
cout << endl;
}
system("pause");
return 0;
}
回到主页
回到目录