当前位置:网站首页>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);
边栏推荐
- SAP HR 社会工作经历 0023
- POJ2392 SpaceElevator [DP]
- PCB wiring rules of PCI Express interface
- Extended tree (I) - graphic analysis and C language implementation
- 产业共融新势能,城链科技数字峰会厦门站成功举办
- Solve the problem of duplicate request resource paths /o2o/shopadmin/o2o/shopadmin/getproductbyid
- B_QuRT_User_Guide(38)
- Matlab SEIR infectious disease model prediction
- In the field of software engineering, we have been doing scientific research for ten years!
- HDU 4747 Mex「建议收藏」
猜你喜欢
B / Qurt Utilisateur Guide (36)
MySQL Index Optimization Practice II
包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态
Solve the problem of duplicate request resource paths /o2o/shopadmin/o2o/shopadmin/getproductbyid
leetcode-520. Detect capital letters -js
B_QuRT_User_Guide(36)
What if once again forgets the login password of raspberry pie? And you don't have a monitor yet! Today, I would like to introduce a method
LM12丨Rolling Heikin Ashi二重K线滤波器
SAP HR奖罚信息导出
Lm12 rolling heikin Ashi double K-line filter
随机推荐
[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware
移动端异构运算技术 - GPU OpenCL 编程(基础篇)
FreeLink开源呼叫中心设计思想
Markdown
In the field of software engineering, we have been doing scientific research for ten years!
Live-Server使用
在软件工程领域,搞科研的这十年!
Markdown
Description of longitude and latitude PLT file format
高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的
Understand TCP's three handshakes and four waves with love
Explain
B_ QuRT_ User_ Guide(36)
The efficient s2b2c e-commerce system helps electronic material enterprises improve their adaptability in this way
1. Sum of two numbers
windows设置redis开启自动启动
As a new force, chenglian premium products was initially injected, and the shares of relevant listed companies rose 150% in response
2022注册测绘师备考开始 还在不知所措?手把手教你怎么考?
HDU 4747 mex "recommended collection"
USB (XVIII) 2022-04-17