当前位置:网站首页>C number of words, plus ¥, longest word, average value
C number of words, plus ¥, longest word, average value
2022-07-07 23:33:00 【Bobo in summer】

static int count(string sentence)
{
int count = 0;
string[] words = new string[100];
words = sentence.Split(' ');
for (int i = 0; i < words.Length; i++)
{
if (words[i] != "")
count++;
}
return count;
}
string sent = Console.ReadLine(); ;
Console.WriteLine("{0} There's something in it {1} Word ", sent, count(sent));


public static string AddDollar(string sentence)
{
string st = string.Empty;
for (int i = 0; i < sentence.Length; i++)
{
if (char.IsLetter(sentence[i]))
{
st += sentence[i] + "$";
}
else
{
st += sentence[i];
}
}
return st;
}
string st = Console.ReadLine();
Console.WriteLine(" Add ¥ The result is {0}", AddDollar(st));

Find the longest word
static string getLongWord(string sentense)
{
string word = "";
string[] words = new string[100];
words = sentense.Split(' ');
for (int i = 0; i < words.Length; i++)
{
if (word.Length < words[i].Length)
{
word = words[i];
}
}
return word;
}
string st = Console.ReadLine();
Console.WriteLine(" The longest word is :{0}", getLongWord(st));


public static void getMaxMinAverSum(out int max, out int min, out double aver, out int sum)
{
int[] nums = new int[10];
max = 0;
min = 50;
sum = 0;
Random rnd = new Random();
for (int i = 0; i < nums.Length; i++)
{
nums[i] = rnd.Next(20, 51);
if (max < nums[i])
max = nums[i];
if (min > nums[i])
min = nums[i];
sum += nums[i];
Console.Write("{0},", nums[i]);
}
aver = (double)sum / nums.Length;
}
int max, min, sum;
double aver;
getMaxMinAverSum(out max, out min, out aver, out sum);
Console.WriteLine(" Maximum {0}, minimum value {1}, Average {2}, and {3}", max, min, aver, sum);

边栏推荐
- Oracle database backup and recovery
- UE4_ Use of ue5 blueprint command node (turn on / off screen response log publish full screen display)
- Design and implementation of spark offline development framework
- B_QuRT_User_Guide(38)
- UE4_ Ue5 combined with Logitech handle (F710) use record
- Markdown
- System design overview
- Digital procurement management system for fresh food industry: help fresh food enterprises solve procurement problems and implement online procurement throughout the process
- sql 数据库执行问题
- Freelink open source call center design idea
猜你喜欢

Progress broadcast | all 29 shield machines of Guangzhou Metro Line 7 have been launched

LDO稳压芯片-内部框图及选型参数

As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response

One week learning summary of STL Standard Template Library

Summary of SQL single table query 2020.7.27

UE4_ Use of ue5 blueprint command node (turn on / off screen response log publish full screen display)

B / Qurt Utilisateur Guide (36)

B_ QuRT_ User_ Guide(36)

B_QuRT_User_Guide(36)

Unity3d learning notes 5 - create sub mesh
随机推荐
Turbo introder common scripts
USB (XVIII) 2022-04-17
SRM supplier cloud collaborative management platform solution for building materials industry to realize business application scalability and configuration
0-1背包问题
Happy gathering time
USB (XVII) 2022-04-15
[stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud
伸展树(一) - 图文解析与C语言实现
MATLAB signal processing [Q & A essays · 2]
SAP HR 社会工作经历 0023
Count the top 10 films at the box office and save them in another file
Archlinux install MySQL
B_QuRT_User_Guide(37)
Dynamic agent explanation (July 16, 2020)
Progress broadcast | all 29 shield machines of Guangzhou Metro Line 7 have been launched
Add data analysis tools in Excel
Solve the problem of duplicate request resource paths /o2o/shopadmin/o2o/shopadmin/getproductbyid
Have all the fresh students of 2022 found jobs? Is it OK to be we media?
Freelink open source call center design idea
Summary of SQL single table query 2020.7.27