Baixe o app para aproveitar ainda mais
Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original
static void Main(string[] args) { // 7 - TELA Console.Write("Digite uma frase:"); string conteudo = Console.ReadLine().ToUpper(); Console.Write("Escreva a parte que você procura: "); string x = Console.ReadLine().ToUpper(); if(verificaCont(conteudo, x)) Console.WriteLine("\n" + x + " está dentro de " + conteudo); else Console.WriteLine("\n" + x + " NÃO está dentro de " + conteudo); Console.ReadKey(); } // 1 public int returnPosicao(int[] vetor, int numero) { for (int i = 0; i < vetor.Length; i++) { if (vetor[i] == numero) return i; } return -1; } //2 public int returnMaior(int[] vetor) { int maior = 0; for (int i = 0; i < vetor.Length; i++) { if (vetor[i] > maior) maior = vetor[i]; } return maior; } //3 public int PesquisaVetor(int[] vetorOrd, int numero) { Array.Sort(vetorOrd); int meio = 0, min = 0, max = vetorOrd.Length - 1; do { meio = (min + max) / 2; if (vetorOrd[meio] == numero) return meio; else if (numero > vetorOrd[meio]) min = meio + 1; else max = meio - 1; } while (min <= max); return -1; } //4 public void InserirnoVetor(int[] vetor, int numero) { int[] VetNovo = new int[vetor.Length + 1]; for (int i = 0; i < VetNovo.Length; i++) { VetNovo[i] = vetor[i]; if(i == (VetNovo.Length - 1)) VetNovo[i] = numero; } } //5 public void ExcluirdoVetor(int[] vet, int numero) { int tamanho = vet.Length; int j = 0; for (int i = 0; i < tamanho; i++) { j = i; if (vet[i] == j) { tamanho--; while (i < tamanho ){ vet[i] = vet[i + 1]; i++; } } i = j; } int[] novoVet = new int[tamanho]; for (int i = 0; i < novoVet.Length; i++) { novoVet[i] = vet[i]; } Console.WriteLine(novoVet); } //6 public void OrdenarVetor(int[] vet) { int menorElement; int aux = 0; for (int i = 0; i < vet.Length; i++) { menorElement = vet[i]; for (int j = i; j < vet.Length; j++) { if (menorElement >= vet[j]) { menorElement = vet[j]; aux = j; } } vet[aux] = vet[i]; vet[i] = menorElement; } Console.WriteLine(vet); } //7 METODO public static Boolean verificaCont(string conteudo, string x) { if (conteudo.Contains(x)) return true; else return false; }
Compartilhar