• Viernes 17 de Mayo de 2024, 07:30

Autor Tema:  Re: SOCORRO AYUDA CON UN PROGRAMA DE MEDICION DE TEMPERATURA  (Leído 709 veces)

amedinadiaz

  • Nuevo Miembro
  • *
  • Mensajes: 20
    • Ver Perfil
Re: SOCORRO AYUDA CON UN PROGRAMA DE MEDICION DE TEMPERATURA
« en: Lunes 17 de Noviembre de 2003, 18:40 »
0
Me piden que haga un programa que al introducirle una serie de temperaturas, las que sean, (scanf), me diga cuantas veces he introducido esa temperatura mediante la siguiente tabla:

Datos introducidos: 0, 0, 1, 2, 3, ,3

- 0 grados 2 veces
- 1 grados 1 veces
- 2 grados 1 veces
- 3 grados 2 veces
.
.
.
-40 grados x veces

Asi hasta 40. Pero el problema es q tengo q acerlo usando arrays. Lo q llevo asta aora os lo pongo aki, ahi sale todo emjor explicado aunque esta en ingles:(tambien estan hechas las 2 primeras partes del programa que me pedian hallar cuantas veces era superior a 30C y cuantas igual a 19C)

#include <stdio.h>

int main (void)

{
   /* Declaring the integers */
   int temp[41];
   int input=0, T=0, n, m;
    int day=0, day2=0, C=0, day3=0;

   printf("Temperature Readings Program.n");
   printf("By Antonio Medina.n");
   printf("MS-DOS Version 1.0n");
   printf("-----------------------------n");
   printf("n");
   printf("Enter temperature readings:n");
   
   while(T!=-999) // Declaring the while loop, as long as Temperature is not -999 it works.
      
   {   
      scanf("%d", &T);
       if((T<0)&&(T>-999))// If the value is negative this 'if' will set it to 0.
      {
          printf("Your value has been set to 0n");
         T=0;
      }
       else if(T>40)// If the value is bigger than 40, this 'if' will set it to 40.
      {
          printf("Your value has been set to 40n");
         T=40;
      }

      temp[input]=T;
      input+=1;
   }
   

    for(n=0; n<=input-2; n++)// With this 'for' loop we are calculating the times
   {
         if(temp[n]>30)
           day=day+1;

   }   
   
   printf("n");
    printf("***Days greater than 30C =%d***n", day);

    for(m=0; m<=input-2; m++)
   {
        if(temp[m]==19)
          day2=day2+1;

   }
   printf("n");
    printf("***Days equal to 19C =%d***n", day2);

    //HASTA AQUI ES DONDE LLEGO, MAS ABAJO SON SOLO INTENTOS MIOS.
   for(C=0; C<41; C++)
   {
      if(temp[input]=C)
         day3=day3+1;
      printf("%dC in %d daysn", C, day3);

   }
      
   
   return 0;
}
He visto cosas que vosotros no creeriais...
Todos esos momentos...se perderan en el tiempo...
como lagrimas en la lluvia...

Por no comprarme la dichosa camara digital!!

Super_G

  • Miembro MUY activo
  • ***
  • Mensajes: 375
    • Ver Perfil
SOCORRO AYUDA CON UN PROGRAMA DE MEDICION DE TEMPERATURAS
« Respuesta #1 en: Miércoles 19 de Noviembre de 2003, 03:43 »
0
la idea de program creo que lo tengo
seria algo asi:

int tem[41];
int t,i,j;
//inifiamos las tems
for(i=1;i<41;i=i+1)
    temp  =  0;
//*ciclo de lectura******
for(i=0;i<50;i=i+1)
{
  printf("entre temperatura:n");
  scanf("%d", &t);
//se incremente la temp ingrseda
  temp[t]=temp[t]+1;
//se muestra las temps
   for(j=1;j<40;j=j+1)  
     
         printf("n",temp[j]);
         
     
   

}
   
//**********************
bueno eso seria por si acaso lo mas seguro es que tenga errores pues lo programa asi directamente