C++ 实验一

这篇博客探讨了C++中cin和cout的使用,相较于printf和scanf,它们提供了更便捷的输入输出方式,尽管长时间使用可能对左手小拇指造成负担。博主强调编程规范和代码美观的重要性,鼓励逐步学习。
摘要由CSDN通过智能技术生成
//从键盘上输入两个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 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值