All pastes #2087157 Raw Edit

georg

public text v1 · immutable
#2087157 ·published 2011-10-05 17:21 UTC
rendered paste body
#include <stdlib.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int num0;
    int numa;
    int numb;
    int numc;
    int numd;
    int min;
    int count = 0;



    cout << "eine beliebige ganze Zahl eingeben:" << endl;

    cin >> num0; cout << endl;

    min = num0;

    numa = sqrt(num0);

while (numa != 0){


    min = min - pow(numa, 2);
    numb = sqrt(min);
    min = min - pow(numb,2);
    numc = sqrt(min);
    min = min - pow(numc,2);
    numd = sqrt(min);
    min = min - pow(numd,2);
    if(min == 0){
        count++;
        cout << "Nr:" << count <<":    " << num0 << " = " << numa << "^2 + " << numb << "^2 + " << numc << "^2 + " << numd << "^2" << endl;
        }

        while (numb!=0){
            numb--;
            min = min - pow(numb,2);
            numc = sqrt(min);
            min = min - pow(numc,2);
            numd = sqrt(min);
            min = min - pow(numd,2);
            if(min == 0){
                count++;
                cout << "Nr:" << count <<":    " << num0 << " = " << numa << "^2 + " << numb << "^2 + " << numc << "^2 + " << numd << "^2" << endl;}

            while (numc!=0){
                numc--;
                min = min - pow(numc,2);
                numd = sqrt(min);
                min = min - pow(numd,2);
                if(min == 0){
                    count++;
                    cout << "Nr:" << count <<":    " << num0 << " = " << numa << "^2 + " << numb << "^2 + " << numc << "^2 + " << numd << "^2" << endl;}




        }
        }
        }

min = num0;
numa--;


    system("Pause");
    return 0;
}