ÓãCÂÛ̳

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á
²é¿´: 1346|»Ø¸´: 11

[Òѽâ¾ö]Ϊʲôһֱ³öÏÖÂÒÂ룿

[¸´ÖÆÁ´½Ó]
·¢±íÓÚ 2023-4-13 17:57:07 | ÏÔʾȫ²¿Â¥²ã |ÔĶÁģʽ

ÂíÉÏ×¢²á£¬½á½»¸ü¶àºÃÓÑ£¬ÏíÓøü¶à¹¦ÄÜ^_^

ÄúÐèÒª µÇ¼ ²Å¿ÉÒÔÏÂÔØ»ò²é¿´£¬Ã»ÓÐÕ˺ţ¿Á¢¼´×¢²á

x
ÓÐÁ½¸ö²»°üº¬¿Õ°××Ö·ûµÄ×Ö·û´® strºÍ substr£¬str µÄ×Ö·û¸öÊý²»³¬¹ý 10£¬substr µÄ×Ö·û¸öÊýΪ 3¡££¨×Ö·û¸öÊý²»°üÀ¨×Ö·û´®½áβ´¦µÄ \0¡££©½« substr ²åÈëµ½ str ÖÐ ASCII Âë×î´óµÄÄǸö×Ö·ûºóÃ棬ÈôÓжà¸ö×î´óÔòÖ»¿¼ÂǵÚÒ»¸ö¡£
ÊäÈëÑùÀý£º
abcab eee
12343 555
Êä³öÑùÀý£º
abceeeab
12345553
#include<iostream>
#include<cstring>
using namespace std;
string a, b;
int main(){
    
    while(cin>>a>>b){
        int c_max=a[0], cnt = 0;
        for(int i =1; i<a.size(); i++){
            if((int)a[i]>c_max) c_max = (int)a[i], cnt = i;
        }
        int j = 0;
        for(int i=0; i<a.size()+b.size(); i++){
            if(i>cnt && i<=cnt+3 ) cout<<b[j], j++;
            else if (i<=cnt) cout<<a[i];
            else cout<<a[i] - 3;
        }
    }
    return 0;
}
×î¼Ñ´ð°¸
2023-4-13 17:57:25
±¾Ìû×îºóÓÉ isdkz ÓÚ 2023-4-13 17:59 ±à¼­

Õâ¶Î´úÂëÊÇÒ»¸ö C++ ³ÌÐò£¬ËüµÄ¹¦ÄÜÊǶÁÈ¡Á½¸ö×Ö·û´®£ºstr ºÍ substr£¬½« substr ²åÈëµ½ str ÖÐ ASCII Âë×î´óµÄ×Ö·ûºóÃæ¡£³ÌÐòÊ×ÏÈÕÒµ½ str ÖÐ ASCII Âë×î´óµÄ×Ö·û£¬È»ºóÔÚ¸Ã×Ö·ûºóÃæ²åÈë substr¡£

ÔÚ´úÂëÖУ¬a ºÍ b ·Ö±ðÊÇÊäÈëµÄ str ºÍ substr ×Ö·û´®¡£ÔÚ while Ñ­»·ÖУ¬³ÌÐò¶ÁÈ¡ÊäÈëµÄÁ½¸ö×Ö·û´®¡£È»ºó£¬Ê¹ÓÃÒ»¸ö for Ñ­»·±éÀú str£¨¼´ a£©£¬ÕÒµ½ ASCII Âë×î´óµÄ×Ö·û¼°ÆäλÖ㨱äÁ¿ cnt£©¡£

½ÓÏÂÀ´£¬³ÌÐòʹÓÃÁíÒ»¸ö for Ñ­»·±éÀú³¤¶ÈΪ a.size()+b.size() µÄ×Ö·û´®£¬Í¨¹ýÌõ¼þÅжÏÀ´Ñ¡ÔñÊä³öԭʼ×Ö·û´® a µÄ×Ö·û¡¢²åÈëµÄ×Ö·û´® b µÄ×Ö·û»òԭʼ×Ö·û´® a ÖеÄÆäËû×Ö·û¡£

µ«ÊÇ£¬´úÂëÖдæÔÚһЩ´íÎó£¬ÎÒ½«ÎªÄúÐÞ¸´ÕâЩ´íÎó£º
#include<iostream>
#include<string>
using namespace std;
string a, b;
int main(){
   
    while(cin>>a>>b){
        int c_max=a[0], cnt = 0;
        for(int i =1; i<a.size(); i++){
            if((int)a[i]>c_max) c_max = (int)a[i], cnt = i;
        }
        int j = 0;
        for(int i=0; i<a.size()+b.size(); i++){
            if(i>cnt && j<b.size()) cout<<b[j++]; // ÔÚ²åÈë substr µÄ¹ý³ÌÖУ¬ÐèÒª¼ì²é j ÊÇ·ñСÓÚ b.size()
            else if (i<=cnt) cout<<a[i];
            else cout<<a[i - b.size()]; // µ± i ´óÓÚ cnt ʱ£¬Ó¦¸ÃÊä³ö a ÖÐÊ£ÓàµÄ×Ö·û£¬ËùÒÔÊÇ a[i - b.size()]
        }
        cout << endl; // Êä³öÒ»¸ö»»Ðзû£¬ÒÔ±ãÊä³ö¶à×éÊý¾Ýʱ¿ÉÒÔ·Ö¸ô¿ª
    }
    return 0;
}

ÏÖÔÚ£¬Õâ¶Î´úÂëÓ¦¸Ã¿ÉÒÔÕýÈ·µØ´¦ÀíÊäÈëÊý¾Ý²¢Êä³öÔ¤ÆڵĽá¹û¡£
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-13 17:57:25 | ÏÔʾȫ²¿Â¥²ã    ±¾Â¥Îª×î¼Ñ´ð°¸   
±¾Ìû×îºóÓÉ isdkz ÓÚ 2023-4-13 17:59 ±à¼­

Õâ¶Î´úÂëÊÇÒ»¸ö C++ ³ÌÐò£¬ËüµÄ¹¦ÄÜÊǶÁÈ¡Á½¸ö×Ö·û´®£ºstr ºÍ substr£¬½« substr ²åÈëµ½ str ÖÐ ASCII Âë×î´óµÄ×Ö·ûºóÃæ¡£³ÌÐòÊ×ÏÈÕÒµ½ str ÖÐ ASCII Âë×î´óµÄ×Ö·û£¬È»ºóÔÚ¸Ã×Ö·ûºóÃæ²åÈë substr¡£

ÔÚ´úÂëÖУ¬a ºÍ b ·Ö±ðÊÇÊäÈëµÄ str ºÍ substr ×Ö·û´®¡£ÔÚ while Ñ­»·ÖУ¬³ÌÐò¶ÁÈ¡ÊäÈëµÄÁ½¸ö×Ö·û´®¡£È»ºó£¬Ê¹ÓÃÒ»¸ö for Ñ­»·±éÀú str£¨¼´ a£©£¬ÕÒµ½ ASCII Âë×î´óµÄ×Ö·û¼°ÆäλÖ㨱äÁ¿ cnt£©¡£

½ÓÏÂÀ´£¬³ÌÐòʹÓÃÁíÒ»¸ö for Ñ­»·±éÀú³¤¶ÈΪ a.size()+b.size() µÄ×Ö·û´®£¬Í¨¹ýÌõ¼þÅжÏÀ´Ñ¡ÔñÊä³öԭʼ×Ö·û´® a µÄ×Ö·û¡¢²åÈëµÄ×Ö·û´® b µÄ×Ö·û»òԭʼ×Ö·û´® a ÖеÄÆäËû×Ö·û¡£

µ«ÊÇ£¬´úÂëÖдæÔÚһЩ´íÎó£¬ÎÒ½«ÎªÄúÐÞ¸´ÕâЩ´íÎó£º
#include<iostream>
#include<string>
using namespace std;
string a, b;
int main(){
   
    while(cin>>a>>b){
        int c_max=a[0], cnt = 0;
        for(int i =1; i<a.size(); i++){
            if((int)a[i]>c_max) c_max = (int)a[i], cnt = i;
        }
        int j = 0;
        for(int i=0; i<a.size()+b.size(); i++){
            if(i>cnt && j<b.size()) cout<<b[j++]; // ÔÚ²åÈë substr µÄ¹ý³ÌÖУ¬ÐèÒª¼ì²é j ÊÇ·ñСÓÚ b.size()
            else if (i<=cnt) cout<<a[i];
            else cout<<a[i - b.size()]; // µ± i ´óÓÚ cnt ʱ£¬Ó¦¸ÃÊä³ö a ÖÐÊ£ÓàµÄ×Ö·û£¬ËùÒÔÊÇ a[i - b.size()]
        }
        cout << endl; // Êä³öÒ»¸ö»»Ðзû£¬ÒÔ±ãÊä³ö¶à×éÊý¾Ýʱ¿ÉÒÔ·Ö¸ô¿ª
    }
    return 0;
}

ÏÖÔÚ£¬Õâ¶Î´úÂëÓ¦¸Ã¿ÉÒÔÕýÈ·µØ´¦ÀíÊäÈëÊý¾Ý²¢Êä³öÔ¤ÆڵĽá¹û¡£
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-13 17:59:27 | ÏÔʾȫ²¿Â¥²ã

Çë²»Òª¹àË®¡­¡­

ɶ£¿ISDKZ£¿
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-13 18:00:48 | ÏÔʾȫ²¿Â¥²ã
Threebody1 ·¢±íÓÚ 2023-4-13 17:59
Çë²»Òª¹àË®¡­¡­

ɶ£¿ISDKZ£¿

ÎÒ²ÅûÓйàË®£¬ÎÒÖ»ÊÇÕ¼¸öÂ¥
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-13 18:35:02 | ÏÔʾȫ²¿Â¥²ã
#include<iostream>
#include<cstring>
using namespace std;
string a, b;
int main(){

    while(cin>>a>>b){
        int c_max=0;
        for(int i =1; i<a.size(); i++){
            if(a[i]>a[c_max]) c_max = i;
        }
        cout<<a.substr(0,c_max+1)<<b<<a.substr(c_max+1,a.size())<<endl;
    }
    return 0;
}
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-13 18:49:39 | ÏÔʾȫ²¿Â¥²ã
±¾Ìû×îºóÓÉ Threebody1 ÓÚ 2023-4-13 18:51 ±à¼­
isdkz ·¢±íÓÚ 2023-4-13 18:00
ÎÒ²ÅûÓйàË®£¬ÎÒÖ»ÊÇÕ¼¸öÂ¥


ÇëÎÊÄãÊÇÔõô×öµ½ÎÞÄÚÈݻظ´µÄ£¿
[b][/b]
£¿ÊÇÕâÑùÂð
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-13 18:57:57 | ÏÔʾȫ²¿Â¥²ã
Threebody1 ·¢±íÓÚ 2023-4-13 18:49
ÇëÎÊÄãÊÇÔõô×öµ½ÎÞÄÚÈݻظ´µÄ£¿

£¿ÊÇÕâÑùÂð


¶ÔµÄ
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-13 19:07:37 | ÏÔʾȫ²¿Â¥²ã

ΪʲôÄãºÍtwilight6µÄ»Ø¸´¶¼»á¼Ó´Ö£¬¶øÕâÌõûÓУ¿
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-14 10:28:26 | ÏÔʾȫ²¿Â¥²ã
Threebody1 ·¢±íÓÚ 2023-4-13 19:07
ΪʲôÄãºÍtwilight6µÄ»Ø¸´¶¼»á¼Ó´Ö£¬¶øÕâÌõûÓУ¿



ÎÒÊǸöÈËÏ°¹ß¼Ó´Ö£¬¸Ð¾õ¿´µÄºÜÊæ·þ

ËùÒÔÿ´Î»Ø´ðÍêÎÊÌâºóÏ°¹ßÐÔ°´Ï Ctrl + A È»ºóµã»÷×óÉÏ½ÇµÄ B ½øÐÐÈ«ÎļӳÉ
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-14 17:25:12 | ÏÔʾȫ²¿Â¥²ã
Twilight6 ·¢±íÓÚ 2023-4-14 10:28
ÎÒÊǸöÈËÏ°¹ß¼Ó´Ö£¬¸Ð¾õ¿´µÄºÜÊæ·þ

ËùÒÔÿ´Î»Ø´ðÍêÎÊÌâºóÏ°¹ßÐÔ°´Ï Ctrl + A È»ºóµã»÷×óÉÏ½ÇµÄ B ...

Ô­À´Èç´Ë
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-14 18:38:03 | ÏÔʾȫ²¿Â¥²ã
Twilight6 ·¢±íÓÚ 2023-4-14 10:28
ÎÒÊǸöÈËÏ°¹ß¼Ó´Ö£¬¸Ð¾õ¿´µÄºÜÊæ·þ

ËùÒÔÿ´Î»Ø´ðÍêÎÊÌâºóÏ°¹ßÐÔ°´Ï Ctrl + A È»ºóµã»÷×óÉÏ½ÇµÄ B ...

»¹ÓÐΪʲôÎÒû at ÄãÄãÒ²À´ÁË£¿
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-4-14 22:30:50 | ÏÔʾȫ²¿Â¥²ã
Threebody1 ·¢±íÓÚ 2023-4-14 18:38
»¹ÓÐΪʲôÎÒû at ÄãÄãÒ²À´ÁË£¿



·­Ìû×Ó ¿´µ½ÄãÌáµ½ÎÒÁËßÂ

ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
ÄúÐèÒªµÇ¼ºó²Å¿ÉÒÔ»ØÌû µÇ¼ | Á¢¼´×¢²á

±¾°æ»ý·Ö¹æÔò

СºÚÎÝ|ÊÖ»ú°æ|Archiver|ÓãC¹¤×÷ÊÒ ( ÔÁICP±¸18085999ºÅ-1 | ÔÁ¹«Íø°²±¸ 44051102000585ºÅ)

GMT+8, 2024-11-18 01:33

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí