//从键盘上输入两个int型数,比较其大小,并输出显示其中较小的数
#include "stdafx.h"
#include <iostream>
using namespace std;
int getSmaller(const int q, const int c);
int main(void)
{
int ssta, isa;
cout << "plz input two shuzi: "<< endl;
cin >> ssta >> isa;
cout << "the smaller one is: "<< getSmaller(ssta, isa) << endl;
return 0;
}
int getSmaller(const int q, const int c)
{
return (q < c ? q : c);
}
//从键盘上输入一个int型数,一个浮点数,比较其大小,将输出其中较大的数
#include "stdafx.h"
#include <iostream>
using namespace std;
float getBigger(const int q, const float c);
int main(void)
{
int ssta;
float isa;
cout << "plz input two shuzi: "<< endl;
cin >> ssta >> isa;
cout << "the Bigger one is: "<< getBigger(ssta, isa) << endl;
return 0;
}
float getBigger(const int q, const float c)
{
return ((float)q > c ? q
C++ 实验一
最新推荐文章于 2018-12-16 11:22:41 发布
这篇博客探讨了C++中cin和cout的使用,相较于printf和scanf,它们提供了更便捷的输入输出方式,尽管长时间使用可能对左手小拇指造成负担。博主强调编程规范和代码美观的重要性,鼓励逐步学习。
摘要由CSDN通过智能技术生成