2019-11-16 20:27

# 首先说明，不是编译器没有关闭的问题。

``````#include <iostream>
using namespace std ;
void merges(double [] , int , double [] , int , double []) ;
int main()
{
double numbers1[80] , numbers2[80] , numbers[80] ;
int count = 0 ;
for (int i = 0 ; i <= count ; i++)
{
if (count == 0)
{
cout << "输入第一个数组的元素个数\n" ;
cin >> count ;
count = count - 1 ;
cout << "依次输入第一个数组的元素\n" ;
}
cin >> numbers1[i] ;
}
int numbers1Size = count + 1 ;
count = 0 ;
for (int i = 0 ; i <= count ; i++)
{
if (count == 0)
{
cout << "输入第二个数组的元素个数\n" ;
cin >> count ;
count = count - 1 ;
cout << "依次输入第二组数组元素\n" ;
}
cin >> numbers2[i] ;
}
int numbers2Size = count + 1 ;
merges(numbers1 , numbers1Size , numbers2 , numbers2Size , numbers) ;
return 0 ;
}

void merges(double numbers1[80] , int numbers1Size , double numbers2[80] , int numbers2Size , int numbers[80])
{
bool changed ;
do
{
changed = false ;
for (int i = 0 ; i < numbers1Size - 1 ; i++)
{
if(numbers1[i] > numbers1[i+1])
{
double savings ;
savings = numbers1[i] ;
numbers1[i] = numbers1[i+1] ;
numbers1[i+1] = savings ;
changed = true ;
}
}
}while (changed) ;
do
{
changed = false ;
for (int i = 0 ; i < numbers2Size - 1 ; i++)
{
if(numbers2[i] > numbers2[i+1])
{
double savings ;
savings = numbers2[i] ;
numbers2[i] = numbers2[i+1] ;
numbers2[i+1] = savings ;
changed = true ;
}
}
}while (changed) ;
int n1 = 0 , n2 = 0;
for (int i = 0 ; i <= numbers1Size + numbers2Size -1 ; i++)
{
if (n1 <= numbers1Size - 1 && n2 <= numbers2Size - 1)
{
if (numbers1[n1] > numbers2[n2])
{
numbers[i] = numbers2[n2] ;
n2++ ;
}
else
{
numbers[i] = numbers1[n1] ;
n1++ ;
}
continue ;
}
if (n1 > numbers1Size - 1)
{
for ( ; n2 <= numbers2Size - 1 ; n2++)
{
numbers[i] = numbers2[n2] ;
i++ ;
}
continue ;
}
if (n2 > numbers2Size - 1)
{
for ( ; n1 <= numbers1Size - 1 ; n1++)
{
numbers[i] = numbers1[n1] ;
i++ ;
}
}
}
cout << "\n\n" << "将两个数组合并后的元素按大小顺序排列如下: " ;
for (int j = 0 ; j <= (numbers1Size + numbers2Size - 1) ; j++)
{
cout << numbers[j] << "  " ;
}
return ;
}
``````

## 求大佬解答！！

• 点赞
• 写回答
• 关注问题
• 收藏
• 复制链接分享
• 邀请回答

#### 1条回答

• QiQaWgYu 2年前

void merges(double [] , int , double [] , int , double []) ;

void merges(double numbers1[80] , int numbers1Size , double numbers2[80] , int numbers2Size , int numbers[80]) {}

声明与实现的形参类型不一样了，好好看看

点赞 评论 复制链接分享