Editing string

本文探讨了在编程中剪辑字符串的各种方法,并通过示例代码展示了如何使用C++进行字符串操作。从基础到进阶,涵盖了字符串的切割、拼接等关键技能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这几天做题碰到了好几道剪辑字符串的题目,自己写了个代码, 背过直接用。

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int n = (int)s.size();
    for(int i = 0; i < n; ++i)
    {
        for(int j = i; j < n; ++j)
        {
            for(int k = 0; k < i; ++k)
            {
                string tmp = s;
                int cnt = 0;
                for(int kk = 0; kk < k; ++kk) tmp[cnt++] = s[kk];
                for(int kk = i; kk <= j; ++kk) tmp[cnt++] = s[kk];
                for(int kk = k; kk < i; ++kk) tmp[cnt++] = s[kk];
                for(int kk = j + 1; kk < n; ++kk) tmp[cnt++] = s[kk];
                cout << tmp << endl;
            }
        }
    }
}


<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>$(DEVELOPMENT_LANGUAGE)</string> <key>CFBundleDisplayName</key> <string>电商小白通</string> <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>digital_human</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>$(FLUTTER_BUILD_NAME)</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>$(FLUTTER_BUILD_NUMBER)</string> <key>LSRequiresIPhoneOS</key> <true/> <key>NSCameraUsageDescription</key> <string>We need access to your camera for taking photos, recording videos, scanning QR codes, and facial recognition functions.</string> <key>NSLocationWhenInUseUsageDescription</key> <string>We need to access your location information to provide location-based services such as navigation and location related search results.</string> <key>NSMicrophoneUsageDescription</key> <string>We need to access your microphone to record audio, which may be used for voice messages or audio recording.</string> <key>NSPhotoLibraryUsageDescription</key> <string>We need to access your photo library so that you can select images from the album for editing and modification.</string> <key>UIApplicationSupportsIndirectInputEvents</key> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <key>UIMainStoryboardFile</key> <string>Main</string> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortraitUpsideDown</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>CADisableMinimumFrameDurationOnPhone</key> <true/> <key>UIApplicationSupportsIndirectInputEvents</key> <true/> <key>UIStatusBarHidden</key> <true/> <key>UIViewControllerBasedStatusBarAppearance</key> <false/> </dict> </plist> 这么写有什么问题
最新发布
08-10
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值