Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // compilacion-> g++ -std=c++11 -o test test.cpp
- #include <iostream>
- using namespace std;
- //----------------------------------------------------------------------
- int ComparaNumeros(float a,float b){
- if ((a-b)==0) {return 0;}// 0 ,Igual ==
- if ((a-b)<0){return -1;}// -1 , a menor a b
- return (1);// 1 ,a es mayor que b
- };
- //----------------------------------------------------------------------
- int main(){
- float a,b;
- while (1){//Bucle de test infinito ....
- cout <<endl;
- cout << "Primer num a=";cin >>a;
- cout << "Segundo num b=";cin >>b;
- switch (ComparaNumeros(a,b)){//Test de la funcion ComparaNumeros
- case 0: cout <<"Igual"<<endl;break;
- case 1 :cout <<"a > b"<<endl;break;
- default :cout <<"a < b"<<endl;break;
- }
- }
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement