//--------------
//
// 411440281 Lu-Wei-Yi
// Date : 2023/10/12
//
//-------------
#include <stdio.h>
#include <stdlib.h>
struct triango{
   int a;
   int b;
   int c;
};

int isTriango(int a,int b,int c){
  int h1 = (a*a+b*b==c*c);
  int h2 = (a*a+c*c==b*b);
  int h3 = (b*b+c*c==a*a);
  return(h1||h2||h3);
};

int main() {
    struct triango *tri = malloc(sizeof(struct triango));
    int count=0;
    int i;
    int j;
    int k;
    for(i=1;i<6;i++){
        for(j=1;j<6;j++){
            for(k=1;k<6;k++){
                tri[count].a=i;
                tri[count].b=j;
                tri[count].c=k;
                count++;
                tri=realloc(tri,(count+1)*sizeof(struct triango));
            }
        }
    }   
    for(i=0;i<count;i++){
        if(isTriango(tri[i].a,tri[i].b,tri[i].c)){
            printf("Triangle %c is number %d is a right triangle with sides : {%d, %d, %d}\n",i,i,tri[i].a,tri[i].b,tri[i].c);
        }
    }
}
//41440281 Lu-Wei-Yi

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: