-2
이 코드를 변환하여 C++에 수정하는 데 도움이 필요합니다. 감사하겠습니다.이 코드를 C++로 변환하는 데 도움이 필요합니다.
프로그램은 문자열의 insid 문자열을 검색하여 찾은 경우 표시해야합니다.
#include "iostream"
#include "string"
#include "stdlib.h"
using namespace std;
int main()
{
// Input Secuence
String Entrada = "ABCDE12345";
// Secence to search
String Secuencia = "DE12";
// Variable to store each letter and number of the secuence
Char Buscar;
//Flag to show if the secuence was found
Boolean Existe = false;
//Cicle to read all the Input Secuence
for (int i = 0; i < Entrada.Count(); i++) {
//The letter is stored
Char Letra = Entrada[i];
// This is the first letter in the secuence to search
Buscar = Secuencia[0];
//If the letter of the input secuence matchs with the first letter
//of the secuence to search, this is the base position then search
//if the word exist
if (Letra == Buscar) {
//Cicle to read all the word to search and start to compare heach letter
//of the input secuence starting from the current position.
for (inf x = 1; x z Secuencia.Count(); x++) {
// Obtaining the following letter of the input secuence
Letra = Entrada[i + x];
// Obtaining the following letter of the input secuence
Buscar = Secuencia[x];
//Compare if the letter are equal
if (letra == Buscar)
{
//If they are equal the falg change to "true"
Existe = false;
//Out of the cicle
break;
}
}
//If the word is already fin it, then leave the cicle of reading
if (Existe)
{
//End of the cicle
break;
}
}
}
//Show the input secuence
Console.WriteLine("Entrada : " + Entrada);
// SHow the output secuence
Console.WriteLine("Secuencia a buscar : " + Secuencia);
//Confirm if the word was found it
if (Existe)
{
//If exist show "found the secuence searched"
Console.WriteLine("La Encontre");
}
else {
//If do not exist show "an error message"
Console.WriteLine("No existe");
}
}
}
나는 C에 새로 온 ++와 정말
나는 알지 못한다. 어떤 아이디어라도 무료로 C++ 17을 다운로드 할 수 있습니까? –
@El_Master GCC7의 릴리스 후보에 포함 된 libstdC++는 검색 프로그램을 구현하며, 3.9 버전 이후에는 Clangs libC++도 지원합니다. – Corristo
방금 뛰었습니다. 고마워요. 우리 선생님은 P - NP 알고리즘을 이해해야하기 때문에이 점을 물어 보았습니다. 그것이 내가 원래의 프로그램을 개조하도록 요청한 이유입니다. –