How to resolve the algorithm Periodic table step by step in the FutureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Periodic table step by step in the FutureBasic programming language
Table of Contents
Problem Statement
Display the row and column in the periodic table of the given atomic number. Let us consider the following periodic table representation. The representation of the periodic table may be represented in various way. The one presented in this challenge does have the following property : Lantanides and Aktinoides are all in a dedicated row, hence there is no element that is placed at 6, 3 nor 7, 3. You may take a look at the atomic number repartitions here. The atomic number is at least 1, at most 118.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Periodic table step by step in the FutureBasic programming language
Source code in the futurebasic programming language
_window = 1
void local fn BuildPeriodicTableArrays
CFArrayRef periodicArr = @[@"",¬
@"H", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"He",¬
@"Li", @"Be", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"B", @"C", @"N", @"O", @"F", @"Ne",¬
@"Na", @"Mg", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"Al", @"Si", @"P", @"S", @"Cl", @"Ar",¬
@"K", @"Ca", @"Sc", @"Ti", @"V", @"Cr", @"Mn", @"Fe", @"Co", @"Ni", @"Cu", @"Zn", @"Ga", @"Ge", @"As", @"Se", @"Br", @"Kr",¬
@"Rb", @"Sr", @"Y", @"Zr", @"Nb", @"Mo", @"Tc", @"Ru", @"Rh", @"Pd", @"Ag", @"Cd", @"In", @"Sn", @"Sb", @"Te", @"I", @"Xe",¬
@"Cs", @"Ba", @"Lu", @"Hf", @"Ta", @"W", @"Re", @"Os", @"Ir", @"Pt", @"Au", @"Hg", @"Tl", @"Pb", @"Bi", @"Po", @"At", @"Rn",¬
@"Fr", @"Ra", @"Lr", @"Rf", @"Db", @"Sg", @"Bh", @"Hs", @"Mt", @"Ds", @"Rg", @"Cn", @"Nh", @"Fl", @"Mc", @"Lv", @"Ts", @"Og",¬
@"", @"", @"La", @"Ce", @"Pr", @"Nd", @"Pm", @"Sm", @"Eu", @"Gd", @"Tb", @"Dy", @"Ho", @"Er", @"Tm", @"Yb", @"", @"",¬
@"", @"", @"Ac", @"Th", @"Pa", @"U", @"NP", @"Pu", @"Am", @"Cm", @"Bk", @"Cf", @"Es", @"Fm", @"Md", @"No", @"", @""]
AppSetProperty( @"periodicTable", periodicArr )
CFArrayRef numbersArr = @[@"",¬
@"1", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"2",¬
@"3", @"4", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"5", @"6", @"7", @"8", @"9", @"10",¬
@"11", @"12", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"", @"13", @"14", @"15", @"16", @"17", @"18",¬
@"19", @"20", @"21", @"22", @"23", @"24", @"25", @"26", @"27", @"28", @"29", @"30", @"31", @"32", @"33", @"34", @"35", @"36",¬
@"37", @"38", @"39", @"40", @"41", @"42", @"43", @"44", @"45", @"46", @"47", @"48", @"49", @"50", @"51", @"52", @"53", @"54",¬
@"55", @"56", @"71", @"72", @"73", @"74", @"75", @"76", @"77", @"78", @"79", @"80", @"81", @"82", @"83", @"84", @"85", @"86",¬
@"87", @"88", @"103", @"104", @"105", @"106", @"107", @"108", @"109", @"110", @"111", @"112", @"113", @"114", @"114", @"116", @"117", @"118",¬
@"", @"", @"57", @"58", @"59", @"60", @"61", @"62", @"63", @"64", @"65", @"66", @"67", @"68", @"59", @"70", @"", @"",¬
@"", @"", @"89", @"90", @"91", @"92", @"93", @"94", @"95", @"96", @"97", @"98", @"99", @"100", @"101", @"102", @"", @""]
AppSetProperty( @"periodicNumbers", numbersArr )
end fn
void local fn BuildWindow
NSInteger i, j, row
CGRect r
CFArrayRef periodicArr, numbersArr
CFStringRef tempStr
periodicArr = fn AppProperty( @"periodicTable" )
numbersArr = fn AppProperty( @"periodicNumbers" )
window _window, @"Periodic Table", ( 0, 0, 700, 400 )
WindowSetBackgroundColor( _window, fn ColorWhite )
j = 0 : row = 350
r = fn CGRectMake( 10, row, 36, 40 )
for i = 1 to 162
if fn StringIsEqual( periodicArr[i], @"" ) then tempStr = @"" else tempStr = fn StringWithFormat( @"%@\n%@", numbersArr[i], periodicArr[i] )
textfield i,, tempStr, r, _window
TextFieldSetBackgroundColor( i, fn ColorBlue )
TextFieldSetTextColor( i, fn ColorWhite )
ControlSetFontWithName( i, @"Menlo", 12.0 )
ControlSetAlignment(i, NSTextAlignmentCenter )
r = fn CGRectOffset( r, 38, 0 )
j++
if ( j == 18 )
row = row - 42
r = fn CGRectMake( 10, row, 36, 40 )
j = 0
end if
next
for i = 1 to 162
if fn StringIsEqual( fn ControlStringValue( i ), @"" ) then ViewRemoveFromSuperview( i )
next
end fn
fn BuildPeriodicTableArrays
fn BuildWindow
HandleEvents
You may also check:How to resolve the algorithm Cantor set step by step in the Nim programming language
You may also check:How to resolve the algorithm Enforced immutability step by step in the Nim programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Go programming language
You may also check:How to resolve the algorithm Sorting algorithms/Quicksort step by step in the Phix programming language
You may also check:How to resolve the algorithm Command-line arguments step by step in the Tailspin programming language