Chemical equation trim "in test" "Not completed"

Source: Internet
Author: User

Periodic table of chemical elements (Element.txt):

1 H hydrogen 1
2 He Helium 4
3 Li Li 7
4 Be Beryllium 9
5 B Boron 11
6 C Carbon 12
7 N Nitrogen 14
8 O Oxygen 16
9 F fluoro 19
20 NE Neon
Na sodium 23
MG MG 24
Al Aluminum 27
Si Silicon 28
P Phosphorus 31
32 S sulfur
CL-Chloro 35.5
AR Argon 40
Potassium k 39
CA Calcium 40
SC scandium 45
TI Titanium 48
V Vanadium 51
CR Chromium 52
MN Manganese 55
56 Fe Iron
Co Cobalt 59
Ni ni 59
CU Copper 64
Zn Zn 66
GA Gallium 70
GE Germanium 73
As Arsenic 75
SE Selenium 79
79 BR bromide
KR Krypton 84
PNS RB-RB 86
SR Strontium 88
Y yttrium 89
Zirconium ZR 91
NB Niobium 93
MO Molybdenum 96
TC 98
Ruthenium RU 101
RH Rhodium 103
PD Palladium 107
Silver AG 108
CD Cadmium 113
115 in Indium
SN 119
SB Antimony 122
128 Te Tellurium
127 I Iodine
XE Xenon 131
CS Cesium 133
137 BA Barium
La lanthanum 139
CE cerium 140
PR Praseodymium 141
nd Neodymium 144
145 Pm Promethium
SM Samarium 151
EU europium 152
GD gadolinium 157
TB Terbium 159
163 DY Dysprosium
165 Ho Holmium
ER erbium 167
TM Thulium 169
Ytterbium YB 173
Lutetium Lu 175
HF Hafnium 179
Tantalum TA 181
184 W Tungsten
186 Re Rhenium
OS osmium 190
192 Ir Iridium
PT Platinum 195
AU gold 197
HG Mercury 201
Bayi TL thallium 205
207 PB Lead
BI Bismuth 209
209 Po Plutonium
At Astatine 210
222 RN Radon
Francium Fr 223
226 RA Radium
Ac 227
TH thorium 232
Protactinium Pa 231
U Uranium 238
Neptunium Np 237
94 Pu Plutonium 244
243 Am Americium
247 Cm.
Berkelium Bk 247
98 Cf Californium 251
Einsteinium Es 252
Fm Fermium 257
101 Md Mendelevium 258
102 No Nobelium 259
103 Lr lawrencium 262
104 Rf Rutherfordium 261
270 Db Zhu Du
106 Sg Zhu Hi 273
107 Bh Zhu Wave 274
108 Hs Zhu Black 272
-1

[Please advise the unfinished code]:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
typedef struct ELEMENT//Element information
{
int an;//Atomic number
Double ar;//relative atomic mass
Char name_cn[3];//Chinese name
Char symbol[4];//element symbols
}ele;
struct material//-Chemical information
{
int hxjls;//stoichiometric number
The atomic number of the int e[30];//element
The number of atoms in the chemical formula for an int num[30];//element
How many elements of int tot;//
};

Ele map[120];
struct Material in[16],out[16];
int in_num=0,out_num=0;//How many reactants/generators
void putsinglematerial (struct Material *input)
{

return;
}
void readsinglematerial (struct Material *input,char first)//for single-chemical inputs
{
Char Ch=first;
Char selt[4];//single element individual elements
int i,i_selt;

input->hxjls=0;//0 Chemical Metering Number
while (' 0 ' <=ch&&ch<= ' 9 ')//ch is part of the stoichiometric number
{
input->hxjls*=10;
input->hxjls+=ch-' 0 ';
scanf ("%c", &ch);
}

input->tot=0;
while (ch!= ' + ' &&ch!= ' = ')//input is the chemical type
{

i_selt=0;
while ((' A ' <=ch&&ch<= ' Z ') | | (' A ' <=ch&&ch<= ' Z ')) Ch belongs to the element part
{
Selt[i_selt]=ch;
i_selt++;
scanf ("%c", &ch);
}
selt[i_selt]= ' + ';
for (i=1;i<=108;i++)//match, determine element atomic number
{
if (strcmp (selt,map[i].symbol) ==0)
{
input->e=i;
}
}//Element input End

while (' 0 ' <=ch&&ch<= ' 9 ')//ch is part of the number of atomic elements
{
input->num[input->tot]=input->num[input->tot]*10+ch-' 0 ';
scanf ("%c", &ch);
}

input->tot++;
}

return;
}
void preload ()//stands for the edit
{
int i;
FILE *ein;
Char ch;
Ein=fopen ("Element.txt", "R");
Input Table of elements
for (i=1;i<=108;i++)
{
Fscanf (ein, "%d", &map[i]. AN);
Fscanf (ein, "%c", &ch);

Fscanf (ein, "%s", Map[i].symbol);
Fscanf (ein, "%c", &ch);

Fscanf (ein, "%s", MAP[I].NAME_CN);
Fscanf (ein, "%c", &ch);

Fscanf (ein, "%lf", &map[i]. AR);
Fscanf (ein, "%c", &ch);
}
Fscanf (ein, "%c", &ch);
Completed!!!

Input chemical equation
struct Material *p;//It will point to the current required input of the chemical formula
scanf ("%c", &ch);
while (ch!= ' = ')//input reactant Group
{
in[in_num].tot=0;//initialization of the number of individual reactant elements
p=&in[in_num];//p points to the current required input chemical formula
Readsinglematerial (p,ch);//single-chemical input
Putsinglematerial (P);
}


return;
}
int main ()//chemical equation trim
{
Preload ();
return 0;
}

Chemical equation trim "in test" "Not completed"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.