Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void pntbubbleSort(float array[][2], int size);
- void swap(float *a, float *b);
- int main(void)
- {
- int points;
- scanf("%d", &points);
- while (points != 0){
- float pointArr[points][2];
- for (int i = 0; i < points; ++i){
- float x, y;
- scanf("%f %f", &x, &y);
- pointArr[i][0] = x;
- pointArr[i][1] = y;
- }
- pntbubbleSort(pointArr, points);
- /*
- for (int i = 0; i < points; ++i){
- printf("%f %f\n", pointArr[i][0], pointArr[i][1]);
- }
- */
- int check = 0;
- int xcheck = pointArr[0][0] + pointArr[points - 1][0];
- int ycheck = pointArr[0][1] + pointArr[points - 1][1];
- for (int i = 0; i < points / 2; ++i){
- if (pointArr[i][0] + pointArr[points - i - 1][0] == xcheck &&
- pointArr[i][1] + pointArr[points - i - 1][1] == ycheck){
- ++check;
- }
- }
- if (check == points / 2){
- printf("yes\n");
- } else {printf("no\n");}
- scanf("%d", &points);
- }
- }
- void pntbubbleSort(float array[][2], int size)
- {
- for (int pass = 1; pass < size; ++pass){
- for (int count = 0; count < size - 1; ++count){
- if (array[count][0] > array[count + 1][0]){
- swap(&array[count][0], &array[count + 1][0]);
- swap(&array[count][1], &array[count + 1][1]);
- }
- else if (array[count][0] == array[count + 1][0]){
- if (array[count][1] > array[count + 1][1]){
- swap(&array[count][0], &array[count + 1][0]);
- swap(&array[count][1], &array[count + 1][1]);
- }
- }
- }
- }
- }
- void swap(float *a, float *b)
- {
- int hold = *a;
- *a = *b;
- *b = hold;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement