AddDrama
Change "." to "!"
If number of "!" is odd , add 1 more "!"
using System;
public class Program
{
public static void Main()
{
string text = "hello. mot! hai!! ba!!!";
string toReturn = "";
var temp = text.Split(' ');
foreach (var item in temp){
int count = 0;
for (int i = 0; i < item.Length; i ++){
if(item[i] == '!'){
count = count + 1;
}
}
if(count % 2 == 1){
toReturn = string.Format("{0}{1}{2}",toReturn,item,"!" );
}
else{
toReturn = string.Format("{0}{1}",toReturn,item );
}
}
toReturn = toReturn.Replace('.','!');
Console.WriteLine(toReturn);
}
}
Aucun commentaire:
Enregistrer un commentaire