rendered paste body// sumfoursquares.cpp// enumerate all possible strictly increasing quadruplets of integers whose squares sum to a given n// by: flamingspinach// 2006-09-13#include <iostream>using namespace std;// UTTERLY horrible brute force method :Dvoid SumFourSquares(int n) { int i[4] = {-n, -n, -n, -n}; while (i[0]*i[0] > n) { ++i[0]; ++i[1]; ++i[2]; ++i[3]; } for(;;) { if (i[0]*i[0] + i[1]*i[1] + i[2]*i[2] + i[3]*i[3] == n) cout << i[0] << " " << i[1] << " " << i[2] << " " << i[3] << " --> " << i[0]*i[0] << " " << i[1]*i[1] << " " << i[2]*i[2] << " " << i[3]*i[3] << endl; if(++i[3]*i[3] > n) if((i[3] = ++i[2]) * i[2] > n) if((i[2] = ++i[1]) * i[1] > n) if((i[1] = ++i[0]) * i[0] > n) break; } return;}int main () { int x; cout << "Please enter an integer n: "; cin >> x; SumFourSquares(x); system("pause"); return(0);}