Skip to content

Instantly share code, notes, and snippets.

@steve-chavez
Created July 28, 2013 01:53
Show Gist options
  • Save steve-chavez/6097026 to your computer and use it in GitHub Desktop.
Save steve-chavez/6097026 to your computer and use it in GitHub Desktop.
TIMUS 1001 STACK AND VECTOR
// 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