-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exercicio01.cs
69 lines (58 loc) · 2.17 KB
/
Exercicio01.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
namespace QuantidadeTermosSequencia
{
class Program
{
static void Main(string[] args)
{
int quantidadeTermos, n;
Console.WriteLine("Exemplo 01 - Quantidade de termos em uma sequência.\n");
Console.Write("Digite uma quantidade de termos: ");
quantidadeTermos = int.Parse(Console.ReadLine());
/* SEQUÊNCIA PADRÃO */
Console.WriteLine("");
for(int i = 1; i <= quantidadeTermos; i++)
{
Console.Write("{0} ",i);
}
Console.WriteLine("- Sequência Padrão.");
/* FIM DA SEQUÊNCIA PADRÃO */
/* SEQUÊNCIA PADRÃO INVERTIDA(DECRESCENTE)*/
Console.WriteLine("");
for(int i = quantidadeTermos; i >= 1; i--)
{
Console.Write("{0} ",i);
}
Console.WriteLine("- Sequência Padrão invertida.");
/* FIM DA SEQUÊNCIA PADRÃO INVERTIDA */
/* SEQUÊNCIA DE MÚLTIPLOS DE 'n' */
Console.Write("\nDigite um valor para 'n': ");
n = int.Parse(Console.ReadLine());
Console.WriteLine("");
for(int i = 1; i <= quantidadeTermos; i++)
{
if(i % n == 0)
{
Console.Write("{0} ",i);
}
else{
quantidadeTermos++;
}
}
Console.WriteLine("- Sequência de múltiplos de 'n'.");
/*FIM SEQUÊNCIA DE MÚLTIPLOS DE 'n' */
//! Essa sequência invertida depende da sequência multíplos de 'n'.
/* SEQUÊNCIA DE MÚLTIPLOS DE 'n' INVERTIDA*/
Console.WriteLine("");
for(int i = quantidadeTermos; i >= 1; i--)
{
if(i % n == 0)
{
Console.Write("{0} ",i);
}
}
Console.WriteLine("- Sequência de múltiplos de 'n' invertida.");
/* FIM DA SEQUÊNCIA DE MÚLTIPLOS DE 'n' INVERTIDA*/
}
}
}