Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Made to test out g++ in Arch, not tested extensively
- #include <iostream>
- #include <stdio.h>
- #include <math.h>
- using namespace std;
- int main ()
- {
- int S,U,V,A,T,Unknown,Temp,Sknown,Uknown,Vknown,Aknown,Tknown,Sfigureable, Ufigureable, Vfigureable, Afigureable, Tfigureable = 0;
- cout << "SUVAT - S = Displacement (Fancy for distance), U = Initial Velocity (Almost always zero), V = Final velocity, A = Acceleration (~10m/s due to gravity), T = time..\n";
- cout << "Is S known? (0 = No, 1 = Yes)\n";
- cin >> Sknown;
- cout << "\nIs U known? \n";
- cin >> Uknown;
- cout << "\nIs V known? \n";
- cin >> Vknown;
- cout << "\nIs A known? \n";
- cin >> Aknown;
- cout << "\nIs T known? \n";
- cin >> Tknown;
- cout << "Calculating what is figurable...\n";
- if (Uknown, Tknown, Aknown == 1 || Uknown, Vknown, Tknown == 1)
- Sfigureable = 1;
- if (Vknown, Aknown, Tknown == 1)
- {
- Ufigureable = 1;
- Vfigureable = 1;
- }
- if (Uknown, Aknown, Sknown == 1)
- Vfigureable = 1;
- if (Vknown, Uknown, Tknown == 1)
- Afigureable = 1;
- if (Vknown, Aknown, Uknown == 1)
- Tfigureable = 1;
- if (Sknown == 1)
- Sfigureable = 0;
- if (Uknown == 1)
- Ufigureable = 0;
- if (Vknown == 1)
- Vfigureable = 0;
- if (Aknown == 1)
- Afigureable = 0;
- if (Tknown == 1)
- Tfigureable = 0;
- if (Sfigureable == 1)
- cout << "S is figurable!\n";
- else if (Sknown == 1)
- cout << "S is already known!\n";
- else cout << "S is not figurable / already known!\n";
- if (Ufigureable == 1)
- cout << "U is figurable!\n";
- else if (Uknown == 1)
- cout << "U is already known!\n";
- else cout << "U is not figurable / already known!\n";
- if (Vfigureable == 1)
- cout << "V is figurable!\n";
- else if (Vknown == 1)
- cout << "V is already known!\n";
- else cout << "V is not figurable / already known!\n";
- if (Afigureable == 1)
- cout << "A is figurable!\n";
- else if (Aknown == 1)
- cout << "A is already known!\n";
- else cout << "A is not figurable / already known!\n";
- if (Tfigureable == 1)
- cout << "T is figurable!\n";
- else if (Tknown == 1)
- cout << "T is already known!\n";
- else cout << "T is not figurable! / already known!\n";
- if (Sknown == 1)
- {
- cout << "S = ";
- cin >> S;
- cout << "\n";
- }
- if (Uknown == 1)
- {
- cout << "U = ";
- cin >> U;
- cout << "\n";
- }
- if (Vknown == 1)
- {
- cout << "V = ";
- cin >> V;
- cout << "\n";
- }
- if (Aknown == 1)
- {
- cout << "A = ";
- cin >> A;
- cout << "\n";
- }
- if (Tknown == 1)
- {
- cout << "T = ";
- cin >> T;
- cout << "\n";
- }
- if (Sfigureable == 1)
- {
- if (Aknown == 1)
- S = U*T + 0.5*A*(T*T);
- else S = 0.5*(U+V)*T;
- }
- if (Ufigureable == 1)
- U = V - A*T;
- if (Vfigureable == 1)
- {
- if (Tknown == 1)
- V = U + A*T;
- else V = sqrt(U^2 + 2*A*S);
- }
- if (Afigureable == 1)
- A = (V-U)/T;
- if (Tfigureable == 1)
- T = (V-U)/A;
- cout << "S: ";
- if (Sknown == 1)
- cout << S << " - ";
- if (Sfigureable == 0)
- cout << "Not figured!\n";
- else cout << S << "\n";
- cout << "U: ";
- if (Uknown == 1)
- cout << U << " - ";
- if (Ufigureable == 0)
- cout << "Not figured!\n";
- else cout << U << "\n";
- cout << "V: ";
- if (Vknown == 1)
- cout << V << " - ";
- if (Vfigureable == 0)
- cout << "Not figured!\n";
- else cout << V << "\n";
- cout << "A: ";
- if (Aknown == 1)
- cout << A << " - ";
- if (Afigureable == 0)
- cout << "Not figured!\n";
- else cout << A << "\n";
- cout << "T: ";
- if (Tknown == 1)
- cout << T << " - ";
- if (Tfigureable == 0)
- cout << "Not figured!\n";
- else cout << T << "\n";
- return 0;
- }
- /*
- U = V - AT
- T = (V-U)/A
- A = (V-U)/T
- */
Advertisement
Add Comment
Please, Sign In to add comment