设为首页收藏本站积分获取及使用技巧附件上传须知一个C程序的问题,现在是输出最大字符串,要求改成可以将两个字符串连接起来。具体请参

追梦工控论坛|工控论坛-专业的Intouch论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

总共8214条微博

动态微博

查看: 2181|回复: 0

一个C程序的问题,现在是输出最大字符串,要求改成可以将两个字符串连接起来。具体请参

[复制链接]
匿名  发表于 2012-12-24 17:09:32 |阅读模式

上传分享工控资料得追梦点,下载积分获取办法点击进入 ☆追梦点充值入口
发帖回帖赚金币兑换下载积分。上传附件须知点击进入

×

马上注册,结交更多工控达人,分享经验,让你轻松玩转追梦工控论坛。

已有帐号?  点击登录   或者        

支付宝扫一扫领红包
程序如下:#if !defined(__STRNG_H )#include<string.h>#endif  // __STRNG_H #ifndef__IOSTREAM_H#include<iostream.h>#endif //// Determines themaximum string using the ASCII collating sequence to // definerank.  A string is defined to be greaterthan another if the// ASCII values ofits characters are greater than the values of the other// string.  For example,//// strngmax AlphaBeta Charlie//// would printCharlie to stdout and return 3.//int main( intargc, char *argv[] ){    if( argc < 2 )        {        cerr << "Usage:  strngmax string1 [string2 ...]\n";        return 1;        }     char *theGreatestString( argv[1] );    int positionOfTheGreatestString = 1;    int nextArg = 2;     while( nextArg < argc )        {        char *argListString ( argv[nextArg++]);        if ( argListString >theGreatestString )            {            theGreatestString = argListString;            positionOfTheGreatestString = nextArg -1;            }        } cout << theGreatestString << endl;     return positionOfTheGreatestString;}
以上程序输入 strngmax 1234 3456 ,则可以得出结果3456那么现在要修改成输入 strngmax 12345 67890 。则得到结果1234567890如果能够给出方法的大致解析我将不胜感激!再追加20分!
来自搜搜问问
让我们联手拒绝网络伸手党,下载积分获取办法&附件上传须知 ☆追梦点充值入口





+1
2181°C
沙发哦 ^ ^ 马上
*滑块验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

请珍惜自己的ID,严禁发布垃圾水贴,诸如adsf......顶......纯表情......多次重复回帖刷积分......轻则删帖警告,重则封禁!★请分享资料、经验或者赞助论坛,贡献一份力量★

关闭

最新活动上一条 /1 下一条

小黑屋|手机版|追梦工控论坛|工控论坛-专业的Intouch论坛 ( 皖ICP备10012005号 )|网站地图

GMT+8, 2025-7-23 02:37 , Processed in 0.108309 second(s), 19 queries , Gzip On, APCu On.

Powered by Dreamyiyi

© 2009-2025 工控论坛

快速回复 返回顶部 返回列表