Cod sursa(job #212935)

Utilizator blizzard30Bolea Catalin blizzard30 Data 7 octombrie 2008 21:07:45
Problema Factorial Scor 5
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
/* 
 * File:   main.cpp
 * Author: Catilin
 *
 * Created on October 7, 2008, 1:20 PM
 */

#include <stdlib.h>
#include <fstream.h>
#include <iostream.h>
ifstream f("fact.in");
ofstream g("fact.out");
//ofstream z("fact.test");
int P;

double fact(int a)
{ double c;
  if (P<5 && P!=0)
  c=5*P;
  else
      if (P>=5)
      c=5*(P-1);
      else
          c=-1;
  return c; 
}

int main(int argc, char** argv) {
f>>P;    
    g<<fact(P);
    f.close();
    g.close();
    //z.close();
    return (0);
}