UVa1587
思路:
1.输入每个面的长宽并将每个面较长的一边放在前面
2.判断是否存在三对面分别相等
3.判断是否存在三组四棱相等
#include <stdio.h>
#include <stdlib.h>
#define maxn 100int cmp(const void* e1, const void* e2)
{return (int)(*(double*)e1 - *(double*)e2);
}int main()
{double h[maxn] = { 0 };double w[maxn] = { 0 };int sign[6] = { 0 };//标记for (int i = 0; i < 6; i++){scanf("%lf %lf", &h[i], &w[i]);if (h[i] < w[i])//把比较大的放前面{double tmp = h[i];h[i] = w[i];w[i] = tmp;}}//判断是否存在三组面两两相等for (int i = 0; i < 6; i++){if (sign[i] == 1){continue;}for (int j = i + 1; j < 6; j++){if (h[i] == h[j]){if (w[i] == w[j]){sign[i] = 1;sign[j] = 1;break;}}}}for (int i = 0; i < 6; i++){if (sign[i] != 1){printf("NO\n");return 0;}}//判断是否存在三组棱4条相等double h_w[maxn] = { 0 };for (int i = 0; i < 6; i++){h_w[i] = h[i];}for (int i = 0; i < 6; i++){h_w[i + 6] = w[i];}qsort(h_w, 12, sizeof(double), cmp);//排序,便于判断每组四条棱是否相等for (int i = 0; i < 12; ){if (h_w[i] == h_w[i + 1] && h_w[i + 1] == h_w[i + 2] && h_w[i + 2] == h_w[i + 3]){i = i + 4;}else{printf("NO\n");return 0;}}printf("YES\n");return 0;
}