Jump to content

Recommended Posts

Posted (edited)
var frAse = "";
var alfa = ["a","b","c","d","e","f","g","h"
,"i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
var frAse = prompt("Introduza a frase:");
var off = prompt("Introduza o deslocamento:");
var x = parseInt(off);
var keep = [];

for(var i=0;i<frAse.length;i++)
{

for(var j=0;j<alfa.length;j++)
{
if(frAse == alfa[j])
{
    keep = alfa[j+x];    
}
}

}
alert(keep.join(""));
Edited by brunoais
geshi
Posted

primeiro de tudo ==== indentação !!!

var frase = "";
var alfa = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
var frase = prompt("Introduza a frase:").toLowerCase();
var off = prompt("Introduza o deslocamento:");
var x = parseInt(off);
var keep = [];

for (var i = 0; i < frase.length; i++)
{
 if(frase[i] != ' ')
 {
   for (var j = 0; j < alfa.length; j++)
   {
     if (frase[i] == alfa[j])
     {
       keep[i] = alfa[(j + x) % alfa.length];
       break;
     }
   }
 }
 else
 {
   keep[i] = ' ';
 }
}
alert(keep.join(""));

IRC : sim, é algo que ainda existe >> #p@p
Posted (edited)

Ups, tens razão! não reparei que a tag code não copiou a indentação sorry! Podias-me dizer o que fizes-te por favor?

Edit: Quer dizer, o que fizes-te na alinea 16 por favor.

Obrigado pelas tips.

Cumps

Edited by AnkH

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.