Calcular tempo de download
Publicado por Frank Junior (última atualização em 31/07/2010)
[ Hits: 14.626 ]
Homepage: http://twitter.com/frankjuniorr
Download Velocidade de Download.c
Um exemplo: eu tenho um arquivo de 700mb pra baixar em uma taxa de transferência a 100kbps por exemplo... quanto tempo vai levar? É isso que o script calcula. ^^
#include <stdio.h>
#include <stdlib.h>
int main(){
float tamanho,velocidade,tempo;
char caractere1,caractere2,resposta;
do{
system("cls");
printf("Legenda Tamanho --> bits=b - Byte=B - KByte=k - Mega=m - Giga=g - Thera=t\n");
printf("Legenda Velocidade --> KByte=k - MegaByte=m = GigaByte=g\n\n");
printf("Digite o Tamanho do Arquivo: ");
scanf("%f",&tamanho);
scanf("%c",&caractere1);
printf("Digite a taxa de Tranferencia da Internet: ");
scanf("%f",&velocidade);
scanf("%c",&caractere2);
if(caractere1 == 'b' && caractere2 == 'k'){
tempo=tamanho/(velocidade*1024*8);
}
if(caractere1 == 'b' && caractere2 == 'm'){
tempo=tamanho/(velocidade*pow(1024,2)*8);
}
if(caractere1 == 'b' && caractere2 == 'g'){
tempo=tamanho/(velocidade*pow(1024,3)*8);
}
if(caractere1 == 'B' && caractere2 == 'k'){
tempo=tamanho/(velocidade*1024);
}
if(caractere1 == 'B' && caractere2 == 'm'){
tempo=tamanho/(velocidade*pow(1024,2));
}
if(caractere1 == 'B' && caractere2 == 'g'){
tempo=tamanho/(velocidade*pow(1024,3));
}
if(caractere1 == 'k' && caractere2 == 'k'){
tempo=tamanho/velocidade;
}
if(caractere1 == 'k' && caractere2 == 'm'){
tempo=tamanho/velocidade*1024;
}
if(caractere1 == 'k' && caractere2 == 'g'){
tempo=tamanho/velocidade*pow(1024,2);
}
if(caractere1 == 'm' && caractere2 == 'k'){
tempo=tamanho*1024/velocidade;
}
if(caractere1 == 'm' && caractere2 == 'm'){
tempo=tamanho/velocidade;
}
if(caractere1 == 'm' && caractere2 == 'g'){
tempo=tamanho/velocidade*1024;
}
if(caractere1 == 'g' && caractere2 == 'k'){
tempo=tamanho*pow(1024,2)/velocidade;
}
if(caractere1 == 'g' && caractere2 == 'm'){
tempo=tamanho*1024/velocidade;
}
if(caractere1 == 'g' && caractere2 == 'g'){
tempo=tamanho/velocidade;
}
if(caractere1 == 't' && caractere2 == 'k'){
tempo=tamanho*pow(1024,3)/velocidade;
}
if(caractere1 == 't' && caractere2 == 'm'){
tempo=tamanho*pow(1024,2)/velocidade;
}
if(caractere1 == 't' && caractere2 == 'g'){
tempo=tamanho*1024/velocidade;
}
if(tempo>=3600){
printf("\nO tempo estimado eh %f Horas\n\n",tempo/3600);
}else{
if(tempo>=60){
printf("\nO Tempo estimado eh %f Minutos\n\n",tempo/60);
}else{
printf("\nO Tempo estimado eh %f Segundos\n\n",tempo);
}
}
printf("Deseja fazer outro calculo? [s/n] ");
resposta = getch();
}while(resposta == 's');
return 1;
}
Calcular taxa de juros com constante em C
Cirurgia para acelerar o openSUSE em HD externo via USB
Void Server como Domain Control
Modo Simples de Baixar e Usar o bash-completion
Monitorando o Preço do Bitcoin ou sua Cripto Favorita em Tempo Real com um Widget Flutuante
[Resolvido] VirtualBox can't enable the AMD-V extension
Como verificar a saúde dos discos no Linux
Como instalar , particionar, formatar e montar um HD adicional no Linux?
Como automatizar sua instalação do Ubuntu para desenvolvimento de software.
Não consigo instalar distro antiga no virtualbox nem direto no hd (14)
Quais os códigos mais dificeis que vcs sabem fazer? (12)
systemd-resol... precisa ser reiniciado periodicamente [RESOLVIDO] (7)









