Skip to content

Instantly share code, notes, and snippets.

@Ryanb58
Created November 30, 2015 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ryanb58/a3a763076ebfacafa745 to your computer and use it in GitHub Desktop.
Save Ryanb58/a3a763076ebfacafa745 to your computer and use it in GitHub Desktop.
C++ Perfect Square using a vector to hold the results.
#include <iostream>
#include <istream>
#include <vector>
#include <string>
using namespace std;
int main() {
string input;
vector<int> squares(100);
for (int i = 0; i < squares.size(); i++)
{
squares[i] = i * i;
}
for (int i = 0; i < squares.size(); i++)
{
cout << i << " " << squares[i] << endl;
}
//Pause before exiting the console.
cin >> input;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment