c语言可执行文件运行出错,C语言 运行显示的是exe文件出错的那个窗口,求大神帮看下哪儿错啦...

C语言 运行显示的是exe文件出错的那个窗口,求大神帮看下哪儿错啦0

还有一道题,依然找不到问题啊,但是也出不来结果,运行显示的是exe文件出错的那个窗口,求大神帮看下哪儿错啦

/*编写一程序P792.C实现以下功能

将命令行输入的三个字符串按从小到大的顺序排序后输出。注意事项:

(1)命令行格式为:P792 str1 str2 str3,当命令行格式不正确(参数个数不为4)时,应报错。

(2)程序的返回值(即由main函数return的值和程序使用exit终止运行时返回的值,也称退出代码)规定为:

①正常运行结束时,返回0  ②命令行格式不对返回1

(3)编程可用素材:printf(" error, usage: P792 str1 str2 str3\n")、printf(" output: %s %s %s\n"…。

程序的运行效果应类似地如图1所示,图1中的E:\Debug>为命令行提示符,表示程序P792.exe所在的文件夹,考生的程序位置可不必如此

图1中的P792 BbcdM89 bbcdM Axyz、P792 BbcdM89 bbcdM Axyz wmv和P792 BbcdM89 bbcdM是从命令行输入的内容。

E:\Debug>P792 BbcdM89 bbcdM Axyz

output: Axyz BbcdM89 bbcdM

E:\Debug>P792 BbcdM89 bbcdM Axyz wmv

error, usage: P792 str1 str2 str3

E:\Debug>P792 BbcdM89 bbcdM

error, usage: P792 str1 str2 str3

E:\Debug>*/

#include

#include

#include

int main(int argc, char *argv[])

{

char *str1, *str2, *str3, *max1, *max2, max3;

if (argc != 4)

{

printf(" error, usage: P792 str1 str2 str3\n");

return 1;

}

str1 = argv[1];

str2 = argv[2];

str3 = argv[3];

if (strcmp(str1, str2) > 0 && strcmp(str1, str3) > 0)

{

max1 = str1;

if(strcmp(str2, str3) > 0)

{

max2 = str2;

max3 = str3;

}

else

{

max2 = str3;

max3 = str2;

}

}

if (strcmp(str2, str1) > 0 && strcmp(str2, str3) > 0)

{

max1 = str2;

if(strcmp(str1, str3) > 0)

{

max2 = str1;

max3 = str3;

}

else

{

max2 = str3;

max3 = str1;

}

}

if (strcmp(str3, str1) > 0 && strcmp(str3, str1) > 0)

{

max1 = str3;

if(strcmp(str1, str2) > 0)

{

max2 = str1;

max3 = str2;

}

else

{

max2 = str2;

max3 = str1;

}

}

printf(" output: %s %s %s\n", max3, max2, max1);

return 0;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值