Advertisement
LightProgrammer000

Palindromo

Jun 17th, 2023
1,111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.54 KB | None | 0 0
  1. // Bibliotecas
  2. import 'dart:io';
  3.  
  4. // Principal
  5. void main(List<String> args) {
  6.   // Entrada de dados
  7.   var n = stdin.readLineSync()!;
  8.  
  9.   // Variaveis
  10.   bool val = false;
  11.   int pos_ini = 0, pos_fim = n.length - 1;
  12.  
  13.   // Estrutura de repeticao
  14.   while (pos_ini < n.length) {
  15.     if (n[pos_ini] == n[pos_fim - pos_ini]) {
  16.       pos_ini++;
  17.     } else {
  18.       print("Nao Palindromo");
  19.       val = false;
  20.       break;
  21.     }
  22.     val = true;
  23.   }
  24.  
  25.   // Condicional: Verdadeiro
  26.   if (val == true) {
  27.     print("# $n: Palindromo");
  28.   }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement