programadoro
New member
- Joined
- Apr 25, 2020
- Messages
- 4
- Programming Experience
- 5-10
how do i get the number of special characters my phrase has, and show them what they are?
how do i show my sentence without the special characters on a single line?
as i read all four notes on a single line, because i'm great at c language, and i know i can use a single scanf for that.
how do i show my sentence without the special characters on a single line?
as i read all four notes on a single line, because i'm great at c language, and i know i can use a single scanf for that.
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);
}
}
}
Last edited by a moderator: