Exemplo n.º 1
0
int main() {
   char line[100];
   int points[6], row[6], col[6];
   int i, n, isvalid;

   while (gets(line), strlen(line)) {
      n = sscanf(line, "%d %d %d %d %d %d", points, points+1, points+2,
		 points+3, points+4, points+5);

      for (i=0; i<n; i++) printf("%d ", points[i]);
      qsort(points, n, sizeof(int), Cmp);
      for (i=0; i<n; i++) {
	 RowCol(points[i], row+i, col+i);
      }
      isvalid = (n==3) ? Triangle(row, col) :
	        (n==4) ? Parallelogram(row, col) :
		(n==6) ? Hexagon(row, col) :
	        0;
      printf("are %sthe vertices of %s\n",
	     isvalid ? "" : "not ",
	     !isvalid ? "an acceptable figure" :
	     n==3 ? "a triangle" :
	     n==4 ? "a parallelogram" : "a hexagon");
   }

   return 0;
}
Parallelogram Parallelogram::operator/(float factor)
{
	return Parallelogram(firstSide / factor, secondSide / factor, intersectionPoint);
}