Created
January 3, 2012 10:41
-
-
Save hhc0null/1554423 to your computer and use it in GitHub Desktop.
aoj-0004-Simultaneous_Equation-1.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iomanip> | |
#include <vector> | |
using namespace std; | |
void ve_calc(double* ary, double* ans) { | |
int i, j, tmp; | |
for(i = 0; i < 2; i++) { | |
*(ans + i) = (ary[2 - 2 * i] * ary[4 + i] - ary[1 + i] * ary[5 - 2 * i]) / (ary[0] * ary[4] - ary[1] * ary[3]) + 0; | |
} | |
// dbg: ok | |
} | |
int main() { | |
int i, j; | |
double tmp; | |
double *ary = new double[6]; | |
vector<double> vect; | |
i = j = 0; | |
/* input */ | |
for(i = 0; cin >> tmp; i++){ | |
vect.push_back(tmp); | |
} | |
// dbg: ok | |
tmp = i / 6; | |
// dbg: ok | |
double *ans = new double[(int)tmp * 2]; | |
// ok | |
/* substitue vect for array */ | |
for(i = 0; i < tmp; i++) { | |
for(j = 0; j < 6; j++) { | |
ary[j] = vect.at(i * 6 + j); | |
} | |
// ok | |
/* call the "ve_calc()" */ | |
ve_calc(ary, ans + i * 2); | |
} | |
// dbg: ok | |
for(i = 0; i < tmp * 2; i += 2) { | |
cout << setprecision(4) << showpoint << ans[i] << " " << ans[i + 1] << endl; | |
} | |
/////////////////////////////////////////////////////// | |
// Oh... My coding skil is too low...? | |
// I must learn more hard! | |
// ...Are there sentences is sure?? | |
// <<MO DO NI DE MO NA RE!!>> | |
/////////////////////////////////////////////////////// | |
delete[] ary; | |
delete[] ans; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment