Cod sursa(job #1179906)
| Utilizator | Data | 29 aprilie 2014 15:49:46 | |
|---|---|---|---|
| Problema | BFS - Parcurgere in latime | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
// istream::putback example
#include <iostream> // std::cin, std::cout
#include <string> // std::string
int main () {
std::cout << "Please, enter a number or a word: ";
char c = std::cin.get();
if ( (c >= '0') && (c <= '9') )
{
int n;
std::cin.putback (c);
std::cin >> n;
std::cout << "You entered a number: " << n << '\n';
}
else
{
std::string str;
std::cin.putback (c);
getline (std::cin,str);
std::cout << "You entered a word: " << str << '\n';
}
std::cin >> c;
return 0;
}