Advertisement
Guest User

Untitled

a guest
Apr 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. bool isHydroxide(string compound)
  9. {
  10. if (compound.substr(compound.length() - 2) == "OH")
  11. return true;
  12. else
  13. return false;
  14. }
  15.  
  16. int main()
  17.  
  18. {
  19. string compound;
  20.  
  21. cout << "Insira um composto quimico: ";
  22. cin >> compound;
  23.  
  24. if (isHydroxide(compound))
  25. cout << "E um hidroxido." << endl;
  26. else
  27. cout << "Nao e um hidroxido." << endl;
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement