Skip to content

Instantly share code, notes, and snippets.

@invatainfo
Created June 10, 2018 10:11
Show Gist options
  • Save invatainfo/8e34652b888eefe8d5424566f0ee1704 to your computer and use it in GitHub Desktop.
Save invatainfo/8e34652b888eefe8d5424566f0ee1704 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string.h>
using namespace std;
/**
* Functie ce imi verifica daca un caracter
* este cifra. Intorc 1 daca e cifra si 0 daca nu e.
*/
int isDigit(char c) {
return c >= '0' && c <= '9';
}
int main() {
char exista = 0, maxDigit = 0;
char sir[101], *p, *number;
cin.get(sir, 100);
p = strtok(sir, " ");
while (p) {
if (isDigit(p[0]) && p[0] > maxDigit) {
maxDigit = p[0];
number = p;
exista = 1;
}
p = strtok(NULL, " ");
}
if (exista == 0) {
cout << "nu exista";
} else
cout << number << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment