当前位置:网站首页>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);

边栏推荐
猜你喜欢

Solution of intelligent supply chain collaboration platform in electronic equipment industry: solve inefficiency and enable digital upgrading of industry

伸展树(一) - 图文解析与C语言实现

高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的

Unity3d learning notes 5 - create sub mesh

13、 System optimization

PCI-Express接口的PCB布线规则
![[compilation principle] lexical analysis design and Implementation](/img/8c/a3a50e6b029c49caf0d791f7d4513a.png)
[compilation principle] lexical analysis design and Implementation

2022注册测绘师备考开始 还在不知所措?手把手教你怎么考?

Explain
![[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
随机推荐
Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
Puce à tension stabilisée LDO - schéma de bloc interne et paramètres de sélection du modèle
Explain
Conversion between commonsmultipartfile and file
UE4_ Ue5 panoramic camera
Entity层、DAO层、Service层、Controller层 先后顺序
Count the top 10 films at the box office and save them in another file
Solution of intelligent supply chain collaboration platform in electronic equipment industry: solve inefficiency and enable digital upgrading of industry
Experience sharing of system architecture designers in preparing for the exam: the direction of paper writing
USB (XVI) 2022-04-28
Oracle database backup and recovery
建筑建材行业SRM供应商云协同管理平台解决方案,实现业务应用可扩展可配置
[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware
Summary of common methods of object class (September 14, 2020)
B_ QuRT_ User_ Guide(39)
云原生数据仓库AnalyticDB MySQL版用户手册
Ros2 topic (03): the difference between ros1 and ros2 [02]
USB (XVII) 2022-04-15
PCB wiring rules of PCI Express interface
Live-Server使用