#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define tam_max 256
int recebe(char principal[tam_max]) {
int erro = 0;
fgets(principal
, tam_max
, stdin
); for (int i
= 0; i
< strlen(principal
); i
++) { if (principal[0] == '\n') {
erro++;
} else if ( principal[i] == '+' || principal[i] == '-' ||
principal[i] == '*' || principal[i] == '/' ||
principal[i] == '=' || principal[i] == '^' ||
principal[i] == 'i' || principal[i] == 'p' ||
principal[i] == '0' || principal[i] == '1' ||
principal[i] == '2' || principal[i] == '3' ||
principal[i] == '4' || principal[i] == '5' ||
principal[i] == '6' || principal[i] == '7' ||
principal[i] == '8' || principal[i] == '9' || principal[i] == '\n') {
erro = 0;
} else {
erro++;
}
}
return erro;
}
void divide() {
}
void validaDados() {
int verifica = 0;
char principal[tam_max];
verifica = recebe(principal);
if (verifica > 0) {
printf("\nCaracteres invalidos inseridos. Por favor, tente novamente.\n\n"); validaDados();
}
if (verifica == 0) {
divide();
}
}
int main() {
validaDados();
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPG1hdGguaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKI2RlZmluZSB0YW1fbWF4IDI1NgoKaW50IHJlY2ViZShjaGFyIHByaW5jaXBhbFt0YW1fbWF4XSkgewogICAgaW50IGVycm8gPSAwOwogICAgc2V0YnVmKHN0ZGluLCBOVUxMKTsKICAgIGZnZXRzKHByaW5jaXBhbCwgdGFtX21heCwgc3RkaW4pOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBzdHJsZW4ocHJpbmNpcGFsKTsgaSsrKSB7CiAgICAgICAgaWYgKHByaW5jaXBhbFswXSA9PSAnXG4nKSB7CiAgICAgICAgICAgIGVycm8rKzsKICAgICAgICB9IGVsc2UgaWYgKCBwcmluY2lwYWxbaV0gPT0gJysnIHx8IHByaW5jaXBhbFtpXSA9PSAnLScgfHwKICAgICAgICAgICAgcHJpbmNpcGFsW2ld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