当前位置:网站首页>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
- B_QuRT_User_Guide(37)
- SAP HR 社会工作经历 0023
- How to login and enable synchronization function in Google browser
- 云原生正在吞噬一切,开发者该如何应对?
- 648. Word replacement
- Coreseek: the second step is index building and testing
- Coreseek:第二步建索引及測试
- USB (XIV) 2022-04-12
- Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
猜你喜欢

在软件工程领域,搞科研的这十年!

Add data analysis tools in Excel
![[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware](/img/bc/8241a339cca9b7af475169dba39c10.jpg)
[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware
![[stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud](/img/78/3cc67a28872ff4d465484cbaee2f6e.jpg)
[stm32+esp8266 connect Tencent cloud IOT development platform 2] stm32+esp8266-01s connect Tencent cloud

包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态

Live-Server使用

电子设备行业智能供应链协同平台解决方案:解决低效, 赋能产业数字化升级

B_QuRT_User_Guide(36)

Explain

Digital procurement management system for fresh food industry: help fresh food enterprises solve procurement problems and implement online procurement throughout the process
随机推荐
Count the top 10 films at the box office and save them in another file
Spark 离线开发框架设计与实现
Opencv scalar passes in three parameters, which can only be displayed in black, white and gray. Solve the problem
POJ2392 SpaceElevator [DP]
Markdown
As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response
LDO稳压芯片-内部框图及选型参数
Illegal behavior analysis 1
JS get the key and value of the object
【7.4】25. K 个一组翻转链表
统计电影票房排名前10的电影并存入还有一个文件
城联优品作为新力量初注入,相关上市公司股价应声上涨150%
FreeLink开源呼叫中心设计思想
USB (XVI) 2022-04-28
USB (XV) 2022-04-14
PHP uses Alibaba cloud storage
建筑建材行业SRM供应商云协同管理平台解决方案,实现业务应用可扩展可配置
Lm12 rolling heikin Ashi double K-line filter
Mysql索引优化实战一
VS扩展工具笔记