logo

대체 모음과 자음 문자열

주어진 문자열에서 모음과 자음이 대체 위치를 차지하도록 주어진 문자열의 문자를 재배열합니다. 문자열을 원하는 방식으로 재배열할 수 없으면 'no such string'을 인쇄하세요. 모음끼리의 순서, 자음끼리의 순서가 유지되어야 한다. 
둘 이상의 필수 문자열을 구성할 수 있는 경우 사전순으로 더 작게 인쇄하십시오.

예:  

Input : geeks Output : gekes Input : onse Output : nose There are two possible outcomes 'nose' and 'ones'. Since 'nose' is lexicographically smaller we print it.
  1. 주어진 문자열에서 모음과 자음의 개수를 셉니다.
  2. 개수 간의 차이가 2보다 크면 '불가능'을 반환합니다.
  3. 자음보다 모음이 많으면 첫 번째 모음을 먼저 인쇄하고 나머지 문자열에 대해 반복됩니다.
  4. 모음보다 자음이 더 많으면 첫 번째 자음을 먼저 인쇄하고 나머지 문자열에 대해 반복됩니다.
  5. 개수가 같으면 첫 번째 모음과 첫 번째 자음을 비교하여 작은 것을 먼저 인쇄합니다.

구현:



C++
// C++ implementation of alternate vowel and // consonant string #include    using namespace std; // 'ch' is vowel or not bool isVowel(char ch) {  if (ch == 'a' || ch == 'e' || ch == 'i' ||  ch == 'o' || ch =='u')  return true;  return false; } // create alternate vowel and consonant string // str1[0...l1-1] and str2[start...l2-1] string createAltStr(string str1 string str2  int start int l) {  string finalStr = '';  // first adding character of vowel/consonant  // then adding character of consonant/vowel  for (int i=0 j=start; j<l; i++ j++)  finalStr = (finalStr + str1.at(i)) + str2.at(j);  return finalStr; } // function to find the required // alternate vowel and consonant string string findAltStr(string str) {  int nv = 0 nc = 0;  string vstr = '' cstr = '';  int l = str.size();  for (int i=0; i<l; i++)  {  char ch = str.at(i);  // count vowels and update vowel string  if (isVowel(ch))  {  nv++;  vstr = vstr + ch;  }  // count consonants and update consonant  // string  else  {  nc++;  cstr = cstr + ch;  }  }  // no such string can be formed  if (abs(nv-nc) >= 2)  return 'no such string';  // remove first character of vowel string  // then create alternate string with  // cstr[0...nc-1] and vstr[1...nv-1]  if (nv > nc)  return (vstr.at(0) + createAltStr(cstr vstr 1 nv));  // remove first character of consonant string  // then create alternate string with  // vstr[0...nv-1] and cstr[1...nc-1]  if (nc > nv)  return (cstr.at(0) + createAltStr(vstr cstr 1 nc));  // if both vowel and consonant  // strings are of equal length  // start creating string with consonant  if (cstr.at(0) < vstr.at(0))  return createAltStr(cstr vstr 0 nv);  // start creating string with vowel  return createAltStr(vstr cstr 0 nc); } // Driver program to test above int main() {  string str = 'geeks';  cout << findAltStr(str);  return 0; } 
Java
// Java implementation of alternate vowel and // consonant string import java.util.*; class GFG { // 'ch' is vowel or not static boolean isVowel(char ch) {  if (ch == 'a' || ch == 'e' || ch == 'i' ||  ch == 'o' || ch =='u')  return true;  return false; } // create alternate vowel and consonant string // str1[0...l1-1] and str2[start...l2-1] static String createAltStr(String str1 String str2  int start int l) {  String finalStr = '';  // first adding character of vowel/consonant  // then adding character of consonant/vowel  for (int i = 0 j = start; j < l; i++ j++)  finalStr = (finalStr + str1.charAt(i)) +  str2.charAt(j);  return finalStr; } // function to find the required // alternate vowel and consonant string static String findAltStr(String str) {  int nv = 0 nc = 0;  String vstr = '' cstr = '';  int l = str.length();  for (int i = 0; i < l; i++)  {  char ch = str.charAt(i);  // count vowels and update vowel string  if (isVowel(ch))  {  nv++;  vstr = vstr + ch;  }  // count consonants and update consonant  // string  else  {  nc++;  cstr = cstr + ch;  }  }  // no such string can be formed  if (Math.abs(nv - nc) >= 2)  return 'no such string';  // remove first character of vowel string  // then create alternate string with  // cstr[0...nc-1] and vstr[1...nv-1]  if (nv > nc)  return (vstr.charAt(0) + createAltStr(cstr vstr 1 nv));  // remove first character of consonant string  // then create alternate string with  // vstr[0...nv-1] and cstr[1...nc-1]  if (nc > nv)  return (cstr.charAt(0) + createAltStr(vstr cstr 1 nc));  // if both vowel and consonant  // strings are of equal length  // start creating string with consonant  if (cstr.charAt(0) < vstr.charAt(0))  return createAltStr(cstr vstr 0 nv);  // start creating string with vowel  return createAltStr(vstr cstr 0 nc); } // Driver code public static void main(String args[]) {  String str = 'geeks';  System.out.println(findAltStr(str)); } } // This code is contributed by // Shashank_Sharma 
Python 3
# Python implementation of alternate vowel # and consonant string  # 'ch' is vowel or not  def isVowel(ch): if(ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u'): return True return False # create alternate vowel and consonant string  # str1[0...l1-1] and str2[start...l2-1]  def createAltStr(str1 str2 start l): finalStr = '' i = 0 # first adding character of vowel/consonant  # then adding character of consonant/vowel  for j in range(start l): finalStr = (finalStr + str1[i]) + str2[j] i + 1 return finalStr # function to find the required  # alternate vowel and consonant string  def findAltStr(str1): nv = 0 nc = 0 vstr = '' cstr = '' l = len(str1) for i in range(0 l): # count vowels and update vowel string  if(isVowel(str1[i])): nv += 1 vstr = vstr + str1[i] # count consonants and update  # consonant string  else: nc += 1 cstr = cstr + str1[i] # no such string can be formed if(abs(nv - nc) >= 2): return 'no such string' # remove first character of vowel string  # then create alternate string with  # cstr[0...nc-1] and vstr[1...nv-1]  if(nv > nc): return (vstr[0] + createAltStr(cstr vstr 1 nv)) # remove first character of consonant string  # then create alternate string with  # vstr[0...nv-1] and cstr[1...nc-1] if(nc > nv): return (cstr[0] + createAltStr(vstr cstr 1 nc)) # if both vowel and consonant  # strings are of equal length  # start creating string with consonant  if(cstr[0] < vstr[0]): return createAltStr(cstr vstr 0 nv) return createAltStr(vstr cstr 0 nc) # Driver Code if __name__ == '__main__': str1 = 'geeks' print(findAltStr(str1)) # This code is contributed by Sairahul099  
C#
// C# implementation of alternate vowel and // consonant string using System; class GFG { // 'ch' is vowel or not static Boolean isVowel(char ch) {  if (ch == 'a' || ch == 'e' || ch == 'i' ||  ch == 'o' || ch =='u')  return true;  return false; } // create alternate vowel and consonant string // str1[0...l1-1] and str2[start...l2-1] static String createAltStr(String str1 String str2  int start int l) {  String finalStr = '';  // first adding character of vowel/consonant  // then adding character of consonant/vowel  for (int i = 0 j = start; j < l; i++ j++)  finalStr = (finalStr + str1[i]) +  str2[j];  return finalStr; } // function to find the required // alternate vowel and consonant string static String findAltStr(String str) {  int nv = 0 nc = 0;  String vstr = '' cstr = '';  int l = str.Length;  for (int i = 0; i < l; i++)  {  char ch = str[i];  // count vowels and update vowel string  if (isVowel(ch))  {  nv++;  vstr = vstr + ch;  }  // count consonants and update consonant  // string  else  {  nc++;  cstr = cstr + ch;  }  }  // no such string can be formed  if (Math.Abs(nv - nc) >= 2)  return 'no such string';  // remove first character of vowel string  // then create alternate string with  // cstr[0...nc-1] and vstr[1...nv-1]  if (nv > nc)  return (vstr[0] + createAltStr(cstr vstr 1 nv));  // remove first character of consonant string  // then create alternate string with  // vstr[0...nv-1] and cstr[1...nc-1]  if (nc > nv)  return (cstr[0] + createAltStr(vstr cstr 1 nc));  // if both vowel and consonant  // strings are of equal length  // start creating string with consonant  if (cstr[0] < vstr[0])  return createAltStr(cstr vstr 0 nv);  // start creating string with vowel  return createAltStr(vstr cstr 0 nc); } // Driver code public static void Main(String []args) {  String str = 'geeks';  Console.WriteLine(findAltStr(str)); } } // This code is contributed by Princi Singh 
JavaScript
<script> // JavaScript implementation of alternate vowel and // consonant string // 'ch' is vowel or not function isVowel(ch) {  if (ch == 'a' || ch == 'e' || ch == 'i' ||  ch == 'o' || ch =='u')  return true;  return false; } // create alternate vowel and consonant string // str1[0...l1-1] and str2[start...l2-1] function createAltStr(str1 str2startl) {  let finalStr = '';  // first adding character of vowel/consonant  // then adding character of consonant/vowel  for (let i=0 j=start; j<l; i++ j++)  finalStr = (finalStr + str1[i] + str2[j]);  return finalStr; } // function to find the required // alternate vowel and consonant string function findAltStr(str) {  let nv = 0 nc = 0;  let vstr = '' cstr = '';  let l = str.length;  for (let i=0; i<l; i++)  {  let ch = str[i];  // count vowels and update vowel string  if (isVowel(ch))  {  nv++;  vstr = vstr + ch;  }  // count consonants and update consonant  // string  else  {  nc++;  cstr = cstr + ch;  }  }  // no such string can be formed  if (Math.abs(nv-nc) >= 2)  return 'no such string';  // remove first character of vowel string  // then create alternate string with  // cstr[0...nc-1] and vstr[1...nv-1]  if (nv > nc)  return (vstr[0] + createAltStr(cstr vstr 1 nv));  // remove first character of consonant string  // then create alternate string with  // vstr[0...nv-1] and cstr[1...nc-1]  if (nc > nv)  return (cstr[0] + createAltStr(vstr cstr 1 nc));  // if both vowel and consonant  // strings are of equal length  // start creating string with consonant  if (cstr.at(0) < vstr.at(0))  return createAltStr(cstr vstr 0 nv);  // start creating string with vowel  return createAltStr(vstr cstr 0 nc); } // Driver program to test above let str = 'geeks'; document.write(findAltStr(str)); // This code is contributed by Shinjan_Patra </script> 

산출
gekes

시간 복잡도: 에) 여기서 'n'은 문자열의 길이입니다.
보조 공간: O(n) 여기서 'n'은 문자열의 길이입니다. 

해싱 기준:

아이디어는 해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''>

해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''>4. 변수 it1 it2 및 i를 선언하여 벡터를 반복하여 첫 번째 모음과 자음을 찾습니다.

해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

mysql 변경 열 유형

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''>

5. 동안 그것1 0과 같습니다:

  • 첫 번째 반복자를 증가시킵니다.

6. 동안 그것2 0과 같습니다:

  • 두 번째 반복자를 증가시킵니다.

7. c가 v보다 크거나 자음이 첫 번째 위치에 올지 또는 모음이 올지 확인하지 않도록 부울 f를 선언합니다. 

8. v가 c와 같은 경우:

    f=it1>it2 (사전순으로 더 작음)

9. it1은 mp1.size()보다 작고 it2는 mp2.size()보다 작고 i는 n보다 작습니다.

  • f가 참이라면 s[i]=it2+'a' --mp2[it2] 그리고 mp2[it2]가 0과 같아질 때까지 mp2를 반복하고 it2 f=false를 증가시킵니다. .
  • 또 다른 s[i]=it1+'a' --mp1[it1] mp1[it1]이 0과 같아질 때까지 mp1을 반복하고 it1 f=true를 증가시킵니다. .
  • i의 증가.

10. 모음이나 자음이 하나만 남는 조건을 확인합니다.

11. 문자열을 반환합니다.

접근법의 구현:

C++
// C++ implementation of alternate vowel and // consonant string #include    using namespace std; string findAltStr(string s) {  int n = s.size();  vector<int> mp1(26)  mp2(26); // to store vowels and consonants  int v = 0 c = 0;  for (char ch : s) {  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o'  || ch == 'u') { // if it's vowel  mp1[ch - 'a']++;  v++;  }  else { // consonant  mp2[ch - 'a']++;  c++;  }  }  if (abs(v - c) > 1)  return 'no such string'; // if their diff is greater than one  // then string with alternate vowel and  // consonant cannot be made  int it1 = 0 it2 = 0 i = 0;  while (it1 < mp1.size() && mp1[it1] == 0)  it1++; // to find first vowel  while (it2 < mp2.size() && mp2[it2] == 0)  it2++; // to find first consonant  bool f  = c > v; // if number of consonant is greater then  // we will place consonant first else vowel  if (v == c) {  f = it1 > it2; // if both are equal then check which  // is lexiographically smaller  }  while ((it1 < mp1.size() && it2 < mp2.size())  && i < n) {  if (f) {  s[i] = it2 + 'a';  --mp2[it2];  while (it2 < mp2.size() && mp2[it2] == 0)  it2++;  f = false; // this will trigger to place vowel  // next  }  else {  s[i] = it1 + 'a';  --mp1[it1];  while (it1 < mp1.size() && mp1[it1] == 0)  it1++;  f = true; // this will trigger to place  // consonant next  }  ++i;  }  if (it1 != mp1.size())  s[i] = it1 + 'a'; // if one vowel left  else if (it2 != mp2.size())  s[i] = it2 + 'a'; // if one consonant left  return s; } // Driver program to test above int main() {  string str = 'geeks';  cout << findAltStr(str);  return 0; } // This code is contributed by Prateek Kumar Singh 
Java
// Java implementation of alternate vowel and // consonant string import java.util.*; public class GFG {  static String findAltStr(String str)  {  char[] s = str.toCharArray();  int n = s.length;  int[] mp1 = new int[26];  int[] mp2  = new int[26]; // to store vowels and consonants  int v = 0 c = 0;  for (char ch : s) {  if (ch == 'a' || ch == 'e' || ch == 'i'  || ch == 'o'  || ch == 'u') { // if it's vowel  mp1[ch - 'a']++;  v++;  }  else { // consonant  mp2[ch - 'a']++;  c++;  }  }  if (Math.abs(v - c) > 1)  return 'no such string'; // if their diff is  // greater than one  // then string with  // alternate vowel and  // consonant cannot be  // made  int it1 = 0 it2 = 0 i = 0;  while (it1 < mp1.length && mp1[it1] == 0)  it1++; // to find first vowel  while (it2 < mp2.length && mp2[it2] == 0)  it2++; // to find first consonant  boolean f = c > v; // if number of consonant is  // greater then we will place  // consonant first else vowel  if (v == c) {  f = it1  > it2; // if both are equal then check which  // is lexiographically smaller  }  while ((it1 < mp1.length && it2 < mp2.length)  && i < n) {  if (f) {  s[i] = (char)(it2 + 'a');  --mp2[it2];  while (it2 < mp2.length && mp2[it2] == 0)  it2++;  f = false; // this will trigger to place  // vowel next  }  else {  s[i] = (char)(it1 + 'a');  --mp1[it1];  while (it1 < mp1.length && mp1[it1] == 0)  it1++;  f = true; // this will trigger to place  // consonant next  }  ++i;  }  if (it1 != mp1.length)  s[i] = (char)(it1 + 'a'); // if one vowel left  else if (it2 != mp2.length)  s[i] = (char)(it2  + 'a'); // if one consonant left  return String.valueOf(s);  }  // Driver program to test above  public static void main(String[] args)  {  String str = 'geeks';  System.out.println(findAltStr(str));  } } // This code is contributed by Karandeep1234 
C#
// C# implementation of alternate vowel and // consonant string using System; class GFG {  static string FindAltStr(string str) {  char[] s = str.ToCharArray();  int n = s.Length;  int[] mp1 = new int[26];  int[] mp2 = new int[26]; // to store vowels and consonants  int v = 0 c = 0;  foreach (char ch in s) {  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') { // if it's vowel  mp1[ch - 'a']++;  v++;  }  else { // consonant  mp2[ch - 'a']++;  c++;  }  }  if (Math.Abs(v - c) > 1)  return 'no such string'; // if their diff is   // greater than one   // then string with  // alternate vowel and  // consonant cannot be   // made  int it1 = 0 it2 = 0 i = 0;  while (it1 < mp1.Length && mp1[it1] == 0)  it1++; // to find first vowel  while (it2 < mp2.Length && mp2[it2] == 0)  it2++; // to find first consonant  bool f = c > v; // if number of consonant is   // greater then we will place   // consonant first else vowel  if (v == c) {  f = it1 > it2; // if both are equal then check which   // is lexiographically smaller  }  while ((it1 < mp1.Length && it2 < mp2.Length) && i < n) {  if (f) {  s[i] = (char)(it2 + 'a');  --mp2[it2];  while (it2 < mp2.Length && mp2[it2] == 0)  it2++;  f = false; // this will trigger to place   // vowel next  }  else {  s[i] = (char)(it1 + 'a');  --mp1[it1];  while (it1 < mp1.Length && mp1[it1] == 0)  it1++;  f = true; // this will trigger to place   // consonant next  }  ++i;  }  if (it1 != mp1.Length)  s[i] = (char)(it1 + 'a'); // if one vowel left  else if (it2 != mp2.Length)  s[i] = (char)(it2 + 'a'); // if one consonant left  return new string(s);  }  // Driver program to test above  public static void Main(string[] args) {  string str = 'geeks';  Console.WriteLine(FindAltStr(str));  } } // This code is contributed by Pushpesh Raj. 
Python3
def findAltStr(s): n = len(s) mp1 = [0]*26 mp2 = [0]*26 # to store vowels and consonants v = 0 c = 0 for ch in s: if ch in ['a' 'e' 'i' 'o' 'u']: # if it's vowel mp1[ord(ch) - ord('a')] += 1 v += 1 else: # consonant mp2[ord(ch) - ord('a')] += 1 c += 1 if abs(v - c) > 1: return 'no such string' # if their diff is greater than one # then string with alternate vowel and # consonant cannot be made it1 = 0 it2 = 0 i = 0 while it1 < len(mp1) and mp1[it1] == 0: it1 += 1 # to find first vowel while it2 < len(mp2) and mp2[it2] == 0: it2 += 1 # to find first consonant f = c > v # if number of consonant is greater then # we will place consonant first else vowel if v == c: f = it1 > it2 # if both are equal then check which # is lexiographically smaller new_str = ['']*n while it1 < len(mp1) and it2 < len(mp2) and i < n: if f: new_str[i] = chr(it2 + ord('a')) mp2[it2] -= 1 while it2 < len(mp2) and mp2[it2] == 0: it2 += 1 f = False # this will trigger to place vowel # next else: new_str[i] = chr(it1 + ord('a')) mp1[it1] -= 1 while it1 < len(mp1) and mp1[it1] == 0: it1 += 1 f = True # this will trigger to place # consonant next i += 1 if it1 != len(mp1): new_str[i] = chr(it1 + ord('a')) # if one vowel left elif it2 != len(mp2): new_str[i] = chr(it2 + ord('a')) # if one consonant left return ''.join(new_str) # Driver program to test above str = 'geeks' print(findAltStr(str)) 
JavaScript
function findAltStr(s) {  const n = s.length;  const mp1 = new Array(26).fill(0);  const mp2 = new Array(26).fill(0); // to store vowels and consonants  let v = 0;  let c = 0;  for (const ch of s) {  if (['a' 'e' 'i' 'o' 'u'].includes(ch)) { // if it's vowel  mp1[ch.charCodeAt(0) - 'a'.charCodeAt(0)] += 1;  v += 1;  } else { // consonant  mp2[ch.charCodeAt(0) - 'a'.charCodeAt(0)] += 1;  c += 1;  }  }  if (Math.abs(v - c) > 1) {  return 'no such string'; // if their diff is greater than one  // then string with alternate vowel and  // consonant cannot be made  }  let it1 = 0;  let it2 = 0;  let i = 0;  while (it1 < mp1.length && mp1[it1] == 0) {  it1 += 1; // to find first vowel  }  while (it2 < mp2.length && mp2[it2] == 0) {  it2 += 1; // to find first consonant  }  let f = c > v; // if number of consonant is greater then  // we will place consonant first else vowel  if (v === c) {  f = it1 > it2; // if both are equal then check which  // is lexiographically smaller  }  const new_str = new Array(n);  while (it1 < mp1.length && it2 < mp2.length && i < n) {  if (f) {  new_str[i] = String.fromCharCode(it2 + 'a'.charCodeAt(0));  mp2[it2] -= 1;  while (it2 < mp2.length && mp2[it2] === 0) {  it2 += 1;  }  f = false; // this will trigger to place vowel  // next  } else {  new_str[i] = String.fromCharCode(it1 + 'a'.charCodeAt(0));  mp1[it1] -= 1;  while (it1 < mp1.length && mp1[it1] === 0) {  it1 += 1;  }  f = true; // this will trigger to place  // consonant next  }  i += 1;  }  if (it1 !== mp1.length) {  new_str[i] = String.fromCharCode(it1 + 'a'.charCodeAt(0)); // if one vowel left  } else if (it2 !== mp2.length) {  new_str[i] = String.fromCharCode(it2 + 'a'.charCodeAt(0)); // if one consonant left  }  return new_str.join(''); } // Driver program to test above const str = 'geeks'; console.log(findAltStr(str)); 

산출
gekes

시간 복잡도: 에)
보조 공간: 에)

이 접근 방식은 다음에 의해 기여됩니다. 프라텍 쿠마르 싱 (pkrsingh025).

 

해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''> 해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''> 해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''> 해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''> 해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''> 해시 테이블 모음과 자음 발생을 저장하려면 간단한 무차별 대입을 적용하십시오.

문제 해결 단계:

1. 발생을 저장하기 위해 벡터 mp1과 mp2를 선언하고 모음과 자음의 개수를 저장하기 위해 변수 v와 c를 선언합니다.

2. 문자열을 반복하고 해시 테이블에서 모음과 자음의 발생을 증가시킵니다.

3. v와 c의 절대차가 1보다 크면 이 경우 모음과 자음을 번갈아 사용하는 문자열은 불가능하므로 'no='' such='' string'을 반환합니다.<='' p=''> 퀴즈 만들기