Programadoro
新成员
- 已加入
- 2020年4月25日
- 留言内容
- 4
- 编程经验
- 5-10
如何获得我的短语中包含的特殊字符的数量,并显示它们的含义?
如何在单行中显示没有特殊字符的句子?
当我在一行上阅读所有四个笔记时,因为我擅长C语言,而且我知道我可以为此使用单个scanf。
如何在单行中显示没有特殊字符的句子?
当我在一行上阅读所有四个笔记时,因为我擅长C语言,而且我知道我可以为此使用单个scanf。
C#:
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
//especificando caracteres exclusivos
string[] separatingStrings = { "<<", "...", "<" };
//escrevendo uma frase qualquer
string text = "one<<two......three<four";
//imprimindo a frase
System.Console.WriteLine($"Original text: '{text}'");
//separando texto dos caracteres exclusivos
string[] words = text.Split(separatingStrings, System.StringSplitOptions.RemoveEmptyEntries);
//quantidade de palavras no texto sem os caracteres exclusivos
System.Console.WriteLine($"{words.Length} Palavras no texto:");
//imprimindo texto sem os caracteres
foreach (var word in words)
{
System.Console.WriteLine(word);
}
}
}
}
C#:
using System;
namespace ConsoleSharp
{
class Program
{
static void Main()
{
int nota1, nota2, nota3, nota4, media;
Console.WriteLine("Entre com 4 notas !");
//ReadLine() retorna uma String, por isso, é preciso converter.
nota1 = Convert.ToInt32(Console.ReadLine());
nota2 = Convert.ToInt32(Console.ReadLine());
nota3 = Convert.ToInt32(Console.ReadLine());
nota4 = Convert.ToInt32(Console.ReadLine());
media = (nota1 + nota2 + nota3 + nota4) / 4;
Console.WriteLine("MEDIA:" + media);
}
}
}
由主持人最后编辑: