View Code of Problem 90

#include<stdio.h>
#include<string.h>
#include<math.h>
#define N 100000

int main()
{
    long int a,b,i,j=0,arr[N];
    double c;
    scanf("%d,%d", &a, &b);
    for(i = a; i <= b; i ++)
    {
        arr[j++] = i;
    }
    for(i = 0; i <= b-a; i ++)
    {
        for(j = 0; j <= b-a; j ++)
        {
            c = sqrt(arr[i]*arr[i] + arr[j]*arr[j]);
            if(c - int(c) < 0.000001)
            {
                //printf("%d\n",c);
                if(c >= a && c <= b && arr[i] < arr[j])
                {
                    printf("%d^2+%d^2=%d^2\n",arr[i],arr[j],int(c));
                }
            }

        }
    }
    return 0;
}

/*
Main.c: In function 'main':
Main.c:10:13: warning: format '%d' expects argument of type 'int *', but argument 2 has type 'long int *' [-Wformat=]
     scanf("%d,%d", &a, &b);
            ~^      ~~
            %ld
Main.c:10:16: warning: format '%d' expects argument of type 'int *', but argument 3 has type 'long int *' [-Wformat=]
     scanf("%d,%d", &a, &b);
               ~^       ~~
               %ld
Main.c:20:20: error: expected expression before 'int'
             if(c - int(c) < 0.000001)
                    ^~~
Main.c:25:61: error: expected expression before 'int'
                     printf("%d^2+%d^2=%d^2\n",arr[i],arr[j],int(c));
                                                             ^~~
*/

Double click to view unformatted code.


Back to problem 90