Ben bu şekilde yaptım fakat daha rahat bir yolu elbet vardır diye düşünüyorum, bilen varsa yazabilir mi ?
<<Write a C++ program to create a new string which is 4 copies of the 2 front characters of a given string. If the given string length is less than 2 return the original string>>
[CODE lang="cpp" title="Benim yaptığım"]string test(string s)
{
return s.length() > 2 ? s.substr(0, 2):s;
}
int main()
{
for (auto i = 1;i <= 4;i++) {
cout << test("Gangamstyle");
}
cout << endl;
}[/CODE]
	
		
			
		
		
	
				
			<<Write a C++ program to create a new string which is 4 copies of the 2 front characters of a given string. If the given string length is less than 2 return the original string>>
[CODE lang="cpp" title="Benim yaptığım"]string test(string s)
{
return s.length() > 2 ? s.substr(0, 2):s;
}
int main()
{
for (auto i = 1;i <= 4;i++) {
cout << test("Gangamstyle");
}
cout << endl;
}[/CODE]
			
				Son düzenleyen: Moderatör: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
	
		
			
		
		
	
								
							
							 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		