1 / 14

Lógica de Programação

Computação Depressão O Portal do Estudante de Computação www.facebook.com/ComputacaoDepressao www.ComputacaoDepressao.com.br. Lógica de Programação. Pascal. String. Variáveis do tipo “ string ” armazenam textos (mais de 1 caractere).

cicily
Download Presentation

Lógica de Programação

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computação Depressão O Portal do Estudante de Computação www.facebook.com/ComputacaoDepressao www.ComputacaoDepressao.com.br Lógica de Programação Pascal

  2. String • Variáveis do tipo “string” armazenam textos (mais de 1 caractere). • Caso queiramos definir um tamanho máximo para a variável, podemos fazer isso, inserindo um valor de 1 a 255. Caso não insiramos, ele automaticamente será de 255 caracteres. • var • a: string; //armazenará até 255 caracteres • b: string[100]; //armazenará até 100 caracteres

  3. Funções e procedimentos que aprenderemos • Quantidade de caracteres • Colocar todas os caracteres em maiúsculo • Colocar todas os caracteres em minúsculo • Concatenação de caracteres • Substring: sequência de caracteres de uma string • Inserir, localizar e apagar uma sequência de caracteres • Conversão entre String e Integer/Real e vice-versa

  4. Quantidade de caracteres • Função: length(string); • var • texto: string; • quantidade: integer; • begin • texto := ‘Computação Depressão’; • quantidade := length(texto); • //variável “quantidade” receberá 20

  5. Todos os caracteres maiúsculos • Função: upcase(string); • var • texto: string; • begin • texto := ‘Computação Depressão’; • texto := upcase(texto); • //variável “texto”receberá “COMPUTAÇÃO DEPRESSÃO”

  6. Todos os caracteres minúsculos • Função: lowercase(string); • var • texto: string; • begin • texto := ‘Computação Depressão’; • texto := lowercase(texto); • //variável “texto” receberá “computação depressão”

  7. Concatenação de caracteres • Função: concat(string, string, ...); • var • nome, sobrenome, completo: string; • begin • nome := ‘Computação’; • sobrenome := ‘Depressão’; • completo := concat(nome, sobrenome); • //variável “completo” receberá “ComputaçãoDepressão”

  8. substring: parte de uma string • Função: copy(string, início, quantidade); • var • texto: string; • begin • texto := ‘Computação Depressão’; • texto := copy(texto, 6, 11); • //iniciar no 6º caractere e pegar 11 caracteres após ele • //variável “texto” receberá “tação Depre”

  9. Inserir uma string numa string • Procedimento: insert(string a ser inserida, string de destino, posição); • var • nome, sobrenome: string; • begin • nome := ‘Compupressão’; • sobrenome := ‘tação De’; • insert(sobrenome, nome, 6); • //variável “nome” receberá “Computação Depressão”

  10. localizar uma string numa string • Função: pos(string a ser procurada, string); • var • texto: string; • posicao: integer; • begin • texto := ‘Computação Depressão’; • posicao := pos(‘pre’, texto); • //variável “posicao” receberá 14. caso não encontre, receberá 0

  11. Deletar uma string de uma string • Procedimento: delete(string, início, quantidade); • var • texto: string; • begin • texto := ‘Computação Depressão’; • delete(texto, 11, 10); • //iniciar no 11º caractere e apagar 10 caracteres após ele • //variável “texto” receberá “Computação”

  12. Conversão de texto em número • Procedimento: val(string, variável numérica, variável de teste); • var • texto: string; • numero, teste: integer; • begin • texto := ‘1234’; • val(texto, numero, teste); • //variável “numero” receberá “1234” e “teste” receberá 0

  13. Conversão de texto em número • Procedimento: val(string, variável numérica, variável de teste); • var • texto: string; • numero, teste: integer; • begin • texto := ‘1234m6’; • val(texto, numero, teste); • //variável “teste” receberá “5” pois o 5º caractere não é número

  14. Conversão de NÚMERO em TEXTO • Procedimento: str(variável numérica, string); • var • texto: string; • numero: integer; • begin • numero := 1234; • str(numero, texto); • //variável “texto” receberá “1234”

More Related