将大写字母依次移至字符串尾部
// 子字符串个数.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include <string>
#include<fstream>
#include <vector>
#define MAX 50
using namespace std;
int main()
{
ifstream infile("E://text.txt");
ofstream outfile("E://result.txt");
if (!infile) { cout << "text.txt open failed" << endl; return 1; }
if (!outfile) { cout << "result.txt open failed" << endl; return 1; }
string str;
getline(infile, str);
outfile << "转换前的字符串为:";
outfile << str << endl;
int n = str.size() - 1;
char temp;
int uppermost= str.size() - 1;
for (int i = n; i >= 0; i--)
{
if (isupper(str[i]))
{
temp = str[i];
for (int j = i ; j < uppermost; j++)
{
str[j] = str[j + 1];
}
str[uppermost] = temp;
uppermost--;
}
}
outfile << "转换后的字符串为:";
outfile << str << endl;
outfile.close();
infile.close();
return 0;
}