diogoAlves

IFF/Introdução à Programação/Slide/Pag 42/Ex 2

Feb 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. //IFF - Introdução à Programação
  2. //Slide - Página 42 - Exercício 2
  3. #include<stdio.h>
  4. #include<locale.h>
  5. #include<string.h>
  6.  
  7. int main(){
  8.     setlocale(LC_ALL,"Portuguese");
  9.     char conteudo[11], tamanho[11], frase1[80], frase2[80];
  10.     printf("Entre com a primeira frase: ");
  11.     gets(frase1);
  12.     printf("Entre com a segunda frase: ");
  13.     gets(frase2);
  14.     printf("Tamanho de \"%s\": %d. \nTamanho de \"%s\": %d.", frase1,strlen(frase1),frase2,strlen(frase2));
  15.     if (stricmp(frase1,frase2)==0) strcpy(conteudo,"iguais"); else strcpy(conteudo,"diferentes");
  16.     if (strlen(frase1)==strlen(frase2)) strcpy(tamanho,"iguais"); else strcpy(tamanho,"diferentes");
  17.     printf("\nAs duas strings tem tamanhos %s.\nAs duas strings tem conteúdos %s.",tamanho,conteudo);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment