I would like to create a program that would electronically distribute atoms, but I'm not sure how to implement them. Would it be as follows? you would place the atomic number and it would return the electronic distribution (K, L, M, N, O, P, Q).
I thought of using if's considering that the layers have a maximum number of electrons:
K = 2
L = 8
M = 18
N = 32
O = 32
P = 18
Q = 8
But there are 2 rules that are:
These two rules bug all my logic. The question is: Does anyone know a better way to implement this project?
Edit: I got a good part now, but the remaining numbers are the same as the valence numbers. Can someone help me to correct this error?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
int z = 53;
int K = 1, L = 555, M = 555, N = 555, O = 555, P = 555, Q = 555;
if (z >= 2) { z -= 2; K = 2; } else { K = z; }
if (z >= 8) { z -= 8; L = 8; }
if (z < 8) L = z;
if (z >= 18) { z -= 18; M = 18; }
if (z <= 8) M = z;
if (z >= 32) { z -= 32; N = 32; }
if (z < 32 && z >= 18) { z -= 18; N = 18; }
if (z <= 8) N = z;
if (z >= 32) { z -= 32; O = 32; }
if (z > 32 && z >= 18) { z -= 18; O = 18; }
if (z <= 8) O = z;
if (z >= 18) { z -= 18; P = 18; }
if (z <= 8) P = z;
if (z >= 8) {z -= 8; Q = 8; }
if (z <= 8) Q = z;
Console.WriteLine("Valores:\nK = " + K + "\nL = " + L + "\nM = " + M + "\nN = " + N + "\nO = " + O + "\nP = " + P + "\nQ = " + Q);
Console.ReadKey();
}
}
}