Здесь вы
void swap( double points[][2], size_t i, size_t j )
{
double ( *a )[2] = points + i;
double ( *b )[2] = points + j;
for ( size_t i = 0; i < 2; i++ )
{
double tmp = ( *a )[i];
( *a )[i] = ( *b )[i];
( *b )[i] = tmp;
}
}
Или полностью без оператора индекса
void swap( double points[][2], size_t i, size_t j )
{
double ( *a )[2] = points + i;
double ( *b )[2] = points + j;
for ( size_t i = 0; i < 2; i++ )
{
double tmp = *( *a + i );
*( *a + i ) = *( *b + i );
*( *b + i ) = tmp;
}
}
Вот демонстрационная программа
#include <stdio.h>
#define N 2
void swap( double points[][N], size_t i, size_t j )
{
double ( *a )[N] = points + i;
double ( *b )[N] = points + j;
for ( size_t i = 0; i < N; i++ )
{
double tmp = *( *a + i );
*( *a + i ) = *( *b + i );
*( *b + i ) = tmp;
}
}
int main(void)
{
double points[][N] =
{
{ 1, 2 }, { 2, 3 }, { 3, 4 }, { 4, 5 }
};
const size_t M = sizeof( points ) / sizeof( *points );
for ( size_t i = 0; i < M; i++ )
{
printf( "{ %.1f, %.1f } ", points[i][0], points[i][1] );
}
putchar( '\n' );
swap( points, 0, 1 );
for ( size_t i = 0; i < M; i++ )
{
printf( "{ %.1f, %.1f } ", points[i][0], points[i][1] );
}
putchar( '\n' );
return 0;
}
Выход программы
{ 1.0, 2.0 } { 2.0, 3.0 } { 3.0, 4.0 } { 4.0, 5.0 }
{ 2.0, 3.0 } { 1.0, 2.0 } { 3.0, 4.0 } { 4.0, 5.0 }