Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- =====================================
- > <
- < FIND EVEN NUMBER >
- > by BlueX <
- < >
- > [iPs]TeaM (c) 2012 <
- < >
- =====================================
- */
- #include <iostream>
- #include <string>
- #include <Windows.h>
- using namespace std;
- char isPrimaryNumber(char Input[]);
- char isNumeric(char Input[]);
- void SendColoredText(string str, int color);
- int restart();
- int main(){
- char userInput[50];
- SendColoredText("\t ============[",14),SendColoredText(" BlueX Find Even Number ",15),SendColoredText("]============\n",14);
- Sleep(1500);
- SendColoredText("Insira um numero: ", 15);
- cin.getline(userInput,50);
- cout << endl;
- if(!isNumeric(userInput)){
- SendColoredText("[",15),SendColoredText("ERRO",4);SendColoredText("]:",15),SendColoredText(" Insira apenas numeros!",15);
- restart();
- }
- if(isPrimaryNumber(userInput)){
- SendColoredText("[ ", 15),SendColoredText("PAR", 2),SendColoredText(" ] - numero: ", 15),SendColoredText(userInput, 15),cout << endl,restart();
- }
- else
- SendColoredText("[ ", 15),SendColoredText("IMPAR", 4),SendColoredText(" ] - numero: ", 15),SendColoredText(userInput, 15),cout << endl,restart();
- //system("pause");
- return 0;
- }
- char isNumeric(char Input[]){
- for(int i = 0, j = strlen(Input); i < j; i++)
- {
- if(Input[i] > '9' || Input[i] < '0') return 0;
- }
- return 1;
- }
- char isPrimaryNumber(char Input[]){
- int pos;
- pos = strlen(Input);
- if(Input[pos-1] == '0' || Input[pos-1] == '2' || Input[pos-1] == '4' || Input[pos-1] == '6' || Input[pos-1] == '8')
- return 1;
- return 0;
- }
- void SendColoredText(string str, int color){
- HANDLE hConsole;
- hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hConsole, color);
- cout << str;
- SetConsoleTextAttribute(hConsole, 15);
- }
- int restart(){
- char a[2];
- int error = 0;
- if(error == 0){
- Sleep(2500);
- system("CLS");
- }
- SendColoredText("Voce deseja restar o programa?\n",15);
- SendColoredText("[N]",4),SendColoredText(" - Nao\n",15);
- SendColoredText("[S]",2),SendColoredText(" - Sim\n",15);
- SendColoredText("Opcao: ",15);
- cin.getline(a,2);
- if(a[0] == 'N' || a[0] == 'n') return 0;
- else if(a[0] == 'S' || a[0] == 's'){
- system("CLS");
- main();
- }
- else {
- SendColoredText("[",15),SendColoredText("ERRO",4);SendColoredText("]:",15),SendColoredText(" Insira apenas S ou N!",15);
- a[0] = '\1';
- restart();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement