\ArrayExchange\main.c|25|error: conflicting types for 'Exchange'|
//题目:数组a中有两组数据元素序列(a0,a1,-----,am-1,b0,b1,----bn-1),把数据元素互换为(b0,b1,----bn-1,a0,a1,---...
//题目:数组a中有两组数据元素序列(a0,a1,-----,am-1,b0,b1,----bn-1),把数据元素互换为
(b0,b1,----bn-1,a0,a1,-----,am-1)
错误提示:\ArrayExchange\main.c|25|error: conflicting types for 'Exchange'|
#define DataType int
#include <stdio.h>
void main(void)
{
int i,a[]={1,2,3,4,5,6,7,8,9};
Exchange(a,7,2);
for(i=0;i<9;i++)
printf("%d",a[i]);
}
void Converse(DataType a[],int low,int high)
{
int n,i;
DataType x;
n=(high-low+1)/2;
for(i=0;i<n;i++)
{
x=a[low+i];
a[low+i]=a[high-i];
a[high-i]=x;
}
}
void Exchange(DataType a[],int m,int n)
{
Converse(a,0,m+n-1);
Converse(a,0,n-1);
Converse(a,n,m+n-1);
} 展开
(b0,b1,----bn-1,a0,a1,-----,am-1)
错误提示:\ArrayExchange\main.c|25|error: conflicting types for 'Exchange'|
#define DataType int
#include <stdio.h>
void main(void)
{
int i,a[]={1,2,3,4,5,6,7,8,9};
Exchange(a,7,2);
for(i=0;i<9;i++)
printf("%d",a[i]);
}
void Converse(DataType a[],int low,int high)
{
int n,i;
DataType x;
n=(high-low+1)/2;
for(i=0;i<n;i++)
{
x=a[low+i];
a[low+i]=a[high-i];
a[high-i]=x;
}
}
void Exchange(DataType a[],int m,int n)
{
Converse(a,0,m+n-1);
Converse(a,0,n-1);
Converse(a,n,m+n-1);
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询