Created
April 24, 2018 01:27
-
-
Save Luccasoli/90a5aa1ccbc35ef855a4d45c781b18c6 to your computer and use it in GitHub Desktop.
Classe Numero e seu makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CXX = g++ | |
CXXFLAGS = -Wall -g | |
main: main.o Numero.o | |
$(CXX) $(CXXFLAGS) -o main main.o Numero.o | |
main.o: main.cpp Numero.o | |
$(CXX) $(CXXFLAGS) -c main.cpp | |
Numero.o: Numero.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Numero.h" | |
#include <bits/stdc++.h> | |
void Numero::gera_num(){ | |
std::srand(std::time(0)); | |
valor = rand() % 10000 + 1; | |
} | |
int Numero::somatorio(){ | |
int soma = 0; | |
for (int i = 1; i <= valor; ++i) | |
{ | |
soma += i; | |
} | |
return soma; | |
} | |
Numero::Numero(){ | |
Numero::gera_num(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
class Numero{ | |
public: | |
int valor; | |
void gera_num(); | |
int somatorio(); | |
Numero(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment