当前位置:编程学习 > VC++ >>

初学VC++,比较从键盘输入的两个数的大小,输出比较大的那个,为什么总是输出较小的呢

#include <iostream> using namespace std; void main() { float i,j,max; cout<<"please input the numbles:"<<endl; cin>>i,j; if(i<j) { max=j; cout<<"the max numble is:"<<endl; cout<<max<<endl; } else { max=i; cout<<"the max numble is:"<<endl; cout<<max<<endl; } }
答案:cin>>i,j;
 
这句话有错,这样能收到的只是i,j并没有接受键盘输入的数据,可以改成cin>>i>>j;这段代码逻辑上没有问题
其他:cin>>i;
 cin>>j;
自己看书cin到底是怎么回事吧,,,,,这样会记得清楚些 

上一个:我遇到一个动态库,里面的两个名字的函数用同一个入口地址,是怎么做到的?_a@0和a相同入口
下一个:#pragma comment(lib, "strmiids.lib") 下面一串 是什么意思啊!!

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,