🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #3221

Re: DUDAS C++

#3221
From: HerrDaur
Date: Fri, 15 Apr 2005 01:59
54 lines
2386 bytes
"jpnews69" <jpnews69@hotmail.com> wrote in message news:<425e747f@x-privat.org>...
> Hola 2 cositas:
> 
> 1. Como puedo tranformar un numero en formato hora. ej: 18,5 0 = "6:30pm"?
> 2. Como puedo medir el tiempo que demora un programa en ejecutarse?, es
> decir, cual es el comando para guardar la hora al inicio y la hora al final
> del prog. para con la diferencia obtener el tiempo que se demora en
> ejecutarse?
> 
> Muchas Gracias!

1. 
float hora_como_numero = 18.5;
int minutos = float(hora_como_numero % 1.0) * 60.0; // valor sin decimales
int hora = int(hora_como_numero) % 12;
boolean am = (int(hora_como_numero) < 12) ? true : false);


pd: no probe el codigo

2. ej sacado de la ayuda de LCC-Win32 (me dio paja buscar mi codigo)

#include <time.h>
#include <stdio.h>
#define RUNS 1000
#define SIZE 10000
int mark[SIZE];
int main (void)
{
    time_t start,finish;
    int i,loop,n,num;
    time(&start);
    /* This loop find the prime numbers between 2 and SIZE */
    for (loop=0; loop<RUNS;++loop) {
        for (n=0; n<SIZE;n++) {
            /* This loop marks all the composite numbers with -1 */
            for (num=0,n=2;n<SIZE;n++) {
                if (!mark[n]) {�
                    for (i=2*n;i<SIZE;i+=n) {
                        mark[i] = -1;
                    }
                }
                num++;
            }
        }
    }
    time(&finish);
    printf("takes");
    printf(" an average of %f seconds to find %d primes",
    difftime(finish,start)/RUNS,num);
}


PD: SI NECESITAS MAS AYUDA, VISITA EL FORO DE POWERS (foro.powers.cl)
Technical Details
Message-ID: <7c842ec8.0504141759.3c4ffaa1@posting.google.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!not-for-mail
References: <425e747f@x-privat.org>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,4523ef30705d6abe
X-Google-Attributes: gid1593cb,public
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!not-for-mail
From: HerrDaur@gmail.com (HerrDaur)
Newsgroups: chile.comp.programacion
Subject: Re: DUDAS C++
Date: 14 Apr 2005 18:59:13 -0700
Organization: http://groups.google.com
Lines: 54
Message-ID: <7c842ec8.0504141759.3c4ffaa1@posting.google.com>
References: <425e747f@x-privat.org>
NNTP-Posting-Host: 200.28.46.150
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1113530353 5595 127.0.0.1 (15 Apr 2005 01:59:13 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 15 Apr 2005 01:59:13 +0000 (UTC)