[Ajuda] Optimizacao do codigo
#1

alguem pode me ajudar a deixar essas linhas em uma se for possivel.

Код:
if(strlen(inputtext) == 1) format(str, sizeof(str), ".);
if(strlen(inputtext) == 2) format(str, sizeof(str), "..);
if(strlen(inputtext) == 3) format(str, sizeof(str), "...);
if(strlen(inputtext) == 4) format(str, sizeof(str), "....);
if(strlen(inputtext) == 5) format(str, sizeof(str), ".....);
if(strlen(inputtext) == 6) format(str, sizeof(str), "......);
if(strlen(inputtext) == 7) format(str, sizeof(str), ".......);
if(strlen(inputtext) == 8) format(str, sizeof(str), "........);
if(strlen(inputtext) == 9) format(str, sizeof(str), ".........);
if(strlen(inputtext) == 10) format(str, sizeof(str), "..........);
Reply
#2

Quote:
Originally Posted by ZaturN
Посмотреть сообщение
alguem pode me ajudar a deixar essas linhas em uma se for possivel.

Код:
if(strlen(inputtext) == 1) format(str, sizeof(str), ".);
if(strlen(inputtext) == 2) format(str, sizeof(str), "..);
if(strlen(inputtext) == 3) format(str, sizeof(str), "...);
if(strlen(inputtext) == 4) format(str, sizeof(str), "....);
if(strlen(inputtext) == 5) format(str, sizeof(str), ".....);
if(strlen(inputtext) == 6) format(str, sizeof(str), "......);
if(strlen(inputtext) == 7) format(str, sizeof(str), ".......);
if(strlen(inputtext) == 8) format(str, sizeof(str), "........);
if(strlen(inputtext) == 9) format(str, sizeof(str), ".........);
if(strlen(inputtext) == 10) format(str, sizeof(str), "..........);
Olб amigo,

se eu fosse vocк, trocaria esses if's por um switch...

essa й a definiзгo do que o seu cуdigo estб fazendo com o processador do seu computador:


cada if desses, com a chamada do mйtodo strlen й uma martelada no seu servidor.

Com o switch vocк chamaria funзгo strlen 1 vez, e redirecionaria o resultado diretamente para o case correto, ao invйs de ficar fazendo estes testes todos.


@EDIT

a soluзгo de baixo nгo vai ser tгo ъtil se vocк quiser fazer verificaзхes mesmo...
Reply
#3

Pense cara, use laзos de repetiзгo, vulgo loops...
PHP код:
for(new istrlen(inputtext); i++)
    
format(strsizeof(str), "%s."str); 
@EDIT

Quote:
Originally Posted by WLSF
Посмотреть сообщение
a soluзгo de baixo nгo vai ser tгo ъtil se vocк quiser fazer verificaзхes mesmo...
Creio que ele quer somente inserir pontos que correspondem ao nъmero de caracteres da string.
Reply
#4

Quote:
Originally Posted by Bruno13
Посмотреть сообщение
Pense cara, use laзos de repetiзгo, vulgo loops...
PHP код:
for(new istrlen(inputtext); i++)
    
format(strsizeof(str), "%s."str); 
@EDIT



Creio que ele quer somente inserir pontos que correspondem ao nъmero de caracteres da string.
sim, eh isso msm q eu qero fazer

#EDIT
vlw, funfo certinho +rep
Reply
#5

PHP код:
new index;
while(
inputtext[index]
{
    
inputtext[index++] = '.';

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)