Jambix64

FuncaoTempleteExer

Jul 14th, 2016
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime> // Biblioteca para Time();
  3. #include <cstdlib> // Biblioteca para SRand();
  4. #include <windows.h> // Biblioteca para titolos de console;
  5. #include <fstream>
  6.   using namespace std;
  7.  
  8.   template < typename t>
  9.    
  10. // Criando funcao templete sobrecarregadas;
  11.   t soma(t i) // se colocar ponto e virgula ocorre um erro de sintaxe;
  12.   {
  13.     t cal1 =    0;
  14.     t cal2 =    0;
  15.     if ( cal1< i || cal2 <i){
  16.          cal1 = i;
  17.          cal2 =  i;
  18.          return cal1+cal2; // Ficou Bugado acredito que esta pegando o buffer da varaivel;
  19.         }
  20.   }
  21.   // fim da primeira funcao templete;
  22.  
  23.  
  24.   int main(){
  25.  
  26.     SetConsoleTitle("Jambix64");
  27.     int var1;
  28.    unsigned int x;
  29.  //  srand(); // Para a pessoa disparar a contagem nao precsa do [TIME()]
  30.    
  31.    cout<<"Quer fazer alguma soma ?,Digite o valor"<<endl;
  32.    cin>>var1;
  33.    cout<<"Digite o Seundo valor para ser somado"<<endl;
  34.    cin>>var1;
  35.    cout<<   soma(var1) <<endl;
  36.    cout<<endl;
  37.    cout<<"Quer fazer UM BACKP ? Digite 1"<<endl;
  38.    cin>>x;
  39.    if(x == 1){
  40.         ofstream backp("text");
  41.     for (int i =0;i<soma(var1);){
  42.       i++; // Encrementando um
  43.       cout<<"%"<<i<<endl;
  44.       system("color 1");
  45.       system("color E");
  46.       backp <<"%"<<i<<endl;
  47.        }
  48.  
  49.    }
  50.   system("pause");
  51.   return 0;
  52.  
  53.   }
Add Comment
Please, Sign In to add comment