刚刚那个"char" 类型的实参与 "const char *" 类型的形参不兼容?
#include<stdio.h>#include<string.h>#include<iostream>#include<math.h>usingnamespacest...
#include <stdio.h>
#include<string.h>
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
char a[4][100];
for (int i = 0; i < 4; i++){
cin>>a[i][100];
}
for (int i = 0; i < 4; i++){
for (int j = 0; j < 3; j++){
if (strcmp(a[i], a[i + 1])>=0){
char tmp = a[i][100];
a[i][100] = a[i + 1][100];
a[i + 1][100] = tmp;
}
}
cout << a[i][100]<<" ";
}
return 0;
} 展开
#include<string.h>
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
char a[4][100];
for (int i = 0; i < 4; i++){
cin>>a[i][100];
}
for (int i = 0; i < 4; i++){
for (int j = 0; j < 3; j++){
if (strcmp(a[i], a[i + 1])>=0){
char tmp = a[i][100];
a[i][100] = a[i + 1][100];
a[i + 1][100] = tmp;
}
}
cout << a[i][100]<<" ";
}
return 0;
} 展开
1个回答
展开全部
#include <stdio.h>
#include<string.h>
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
char a[4][100]={0}, tmp[100]={0};
for (int i=0;i<4;i++)
{
cin>>a[i];
}
for (i=0;i<4-1;i++)
{
for (int j=0;j<4-i-1;j++)
{
if (strcmp(a[j], a[j+1])>=0)
{
strcpy(tmp,a[j]);
strcpy(a[j],a[j+1]);
strcpy(a[j+1], tmp);
}
}
}
for (i=0;i<4;i++)
{
cout<<a[i]<<endl;
}
return 0;
}
zxc
asd
qwe
123
123
asd
qwe
zxc
Press any key to continue
刚才没采纳我 还不得我来善后
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询