Created
July 28, 2013 01:53
-
-
Save steve-chavez/6097026 to your computer and use it in GitHub Desktop.
TIMUS 1001 STACK AND VECTOR
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
// VECTOR | |
#include <math.h> | |
#include <vector> | |
#include <stdio.h> | |
using namespace std; | |
int main(){ | |
double x; | |
vector<double> xs; | |
while (scanf("%lf", &x) != -1) { | |
xs.push_back(x); | |
} | |
for(int i=xs.size()-1; i>=0; i--){ | |
printf("%.4f\n", sqrt(xs.at(i))); | |
} | |
return 0; | |
} | |
// STACK | |
// #include <math.h> | |
// #include <stack> | |
// #include <stdio.h> | |
// using namespace std; | |
// int main(){ | |
// double x; | |
// stack<double> xs; | |
// while (scanf("%lf", &x) != -1) { | |
// xs.push(x); | |
// } | |
// while (!xs.empty()){ | |
// printf("%.4f\n", sqrt(xs.top())); | |
// xs.pop(); | |
// } | |
// return 0; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment