sp******@gmail.com schrieb:
#include <cmath>Why is the referenceNumber a string?
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
struct Catigory{
string refrenceNumber;
string prognose;Are there always *exactly* six alternatives? The alternatives could be a
// This catigories is only for use latter
string catigory1;
string catigory2;
string catigory3;
string catigory4;
string catigory5;
string catigory6;
std::deque which can resize as needed.
};string?
struct Pharmacology{
// char disease[50];a
string refrenceNumber;
struct Alternative{Are there always at most three alternatives? Could be a std::deque, too.
string drug;
string manufacture;
string dosage;
string drugOne;
string manufactureOne;
string dosageOne;
string drugTwo;
string manufactureTwo;
string dosageTwo;
string drugThree;
string manufactureThree;
string dosageThree;
};
>These could be members of the respective classes.
void printCatigory(Catigory& cat);
void printMedicine(Pharmacology& pharma);
void printAlternative(Alternative& alter);
struct Catigory disorder[]={[snipped lots of data]
{"1","Epilepsy","none","none","none","none","none" ,"none"},
{"2","Epilepsy","none","none","none","none","none" ,"none"},
You could read in the data from a file. It is not good to place all the
data in the main source code. At least it could be stored in a separate
source file.
{"3","Epilepsy","none","none","none","none","none" ,"none"},The reference number is hard to maintain here. What if you need to
insert a record? Why keep the reference number in a "Catigory" when it
is given by the array index?
{"44","Debax","Captorpril","ACELots of duplicate data. Maybe you could redesign your data model in a
Hemmer","Antihypertensive","none","cave","??","ÖA K"},
{"45","Lopirin","Captorpril","ACE
Hemmer","Antihypertensive","none","cave","??","ÖA K"},
{"46","Renitec","Enalapril","ACE
Hemmer","Antihypertensive","none","cave","??","ÖA K"},
way to reduce duplicate data.
int medicineSize=(sizeof medicine)/(sizeof medicine[0]);These two variables could be declared "const".
int disorderSize=(sizeof disorder)/(sizeof disorder[0]);
/*int first;You could remove the "cin.ignore" calls if you place a "cin >>
int last;
cout << "Input your the Place of your First Characheter" << endl;
cin >first;
cin.ignore(255,'\n');
cout << "Input your the Place of your Last Characheter" << endl;
cin >last;
cin.ignore(225,'\n');
noskipws;" in front of your program.
switch(menu){Put the source code in the "case"s into separate functions. Make "main"
case 1:
shorter.
cout << " " << endl;This code is in every "case". Place it in front of the "switch".
cout << " " << endl;
>Replace the "1652" by "medicineSize". You could easily forget to update
do{
string generic;
cout << "Input the genericName" << endl;
getline(cin, generic);
for (int i=0; i<1652;i++){
the number otherwise.
string s2 =medicine[i].genericName;Use a associative container for lookup, like std::map. Or use a more
// if (generic.substr(first, last) == s2.substr(first,last) ){
if (generic.substr(0, 4) == s2.substr(0,4) ){
efficient lookup algorithm, like std::lower_bound.
void printMedicine(Pharmacology& pharma){Only use "endl" at the end of the function. "endl" will be much slower than
cout << "Trade Name: " <<pharma.tradeName << endl;
cout << "Generic Name: " <<pharma.genericName << endl;
cout << "Classification: " <<pharma.classification << endl;
cout << "Use: " << pharma.use << endl;
cout << "Hinwiese: " <<pharma.hinweise << endl;
cout << "Cave: " << pharma.cave << endl;
cout << "Dosage: " << pharma.dosageForm << endl;
cout << "Source: " << pharma.source << endl;
cout << "------------------------------------------------------" <<
endl;
//cout << "Refrence Number: " <<pharma.refrenceNumber << endl;
}
cout << '\n'
because it will wait until the data is written to the screen, it will
flush the output buffer. This is needless when you output further data
immediately.
These advises should give you some work to do.
Regads,
Frank