Server IP : 172.16.15.8 / Your IP : 18.117.166.52 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/rnlink/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
#include <iostream> #include <string> using namespace std; int main() { struct Reaction { string chem1, chem2; int tempChange; }; struct ChemBottle { string chembot; int amt; }; string tmpstring, dummystr, chem1, chem2, chembot; int amt, i = 0, j= 0; Reaction reactions[64], dummy; ChemBottle bottle[12]; cin >> chem1; while(chem1 != "ENDOFINPUT") { while(chem1 != "0") { cin >> chem2; cin >> amt; // cout << "Chem1: " << chem1 << "\tChem2: " << chem2 << "\n"; // cout << "Your amount is: " << amt << ".\n"; reactions[i].chem1 = chem1; reactions[i].chem2 = chem2; reactions[i].tempChange = amt; i++; cin >> chem1; } cin >> dummystr; cin >> dummystr; cin >> chembot; while (chembot != "0") { cin >> amt; // cout << "Chembot: " << chembot << "\n"; // cout << "Your amount is: " << amt << ".\n"; bottle[j].chembot = chembot; bottle[j].amt = amt; j++; cin >> chembot; } cin >> dummystr; cin >> chem1; // Sorting // for(int a = 0; a < i-1; a++) { for(int b = 0; b < i-1; b++) { if(reactions[b].tempChange < reactions[b+1].tempChange) { dummy = reactions[b]; reactions[b] = reactions[b+1]; reactions[b+1] = dummy; } } } cout << "Chemical's and their Temps: \n"; for(int c = 0; c < i; c++) { cout << "Chem1: " << reactions[c].chem1 << "\t"; cout << "Chem2: " << reactions[c].chem2 << "\n"; cout << "TempChange: " << reactions[c].tempChange << "\n"; } cout << "\n\nPossible reactions: \n"; for( int d = 0; d < j; d++) { cout << "Chembot: " << bottle[d].chembot << "\n"; cout << "Amount: " << bottle[d].amt << "\n"; } cout << "\n\n\nNext set: \n\n"; i = 0; j = 0; } return 0; }