Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created September 16, 2017 15:00
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 invatainfo/a8dc3d0bea9f01f4d6e382bf91dcbe80 to your computer and use it in GitHub Desktop.
Save invatainfo/a8dc3d0bea9f01f4d6e382bf91dcbe80 to your computer and use it in GitHub Desktop.
#include <fstream.h>
#include <math.h>
ifstream f("bac.txt");
void main() {
int n, m = 0, x, a[50], i;
f >> n;
for (i = 1; i <= n; i++) {
f >> x;
if (sqrt(x) == floor(sqrt(x))) {
m++;
a[m] = x;
}
}
int s = 0;
for (i = 1; i < m; i++) {
cout << a[i] << "+";
s = s + a[i];
}
cout << a[m] << "=";
s = s + a[m];
cout << s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment