stone.cpp

来自「我学习C++ Primer Plus过程中写下的课后作业的编程代码」· C++ 代码 · 共 38 行

CPP
38
字号
// stone.cpp -- user-defined conversions
// compile with stonewt.cpp
#include <iostream>
#include "stonewt.h"

const int arraySize = 6;
int main()
{
	using std::cout;
    using std::endl;
    using std::cin ;
	Stonewt compare(11,0);
	Stonewt max;
	Stonewt min;
	int     biger = 0;
	double  temp;
	Stonewt weight[6] = { 260, (285.7), (21, 8) };
	for( int i = 3; i < arraySize; i++ )
	{
	   cout<<"请输入体重(pounds):";
	   cin>>temp;
	   weight[i] = temp;
	}
	max = min = weight[0];
	for( i = 0; i < arraySize; i++ )
	{
		cout<<weight[i]<<endl;
		max = ( max<weight[i] ) ? weight[i] : max;
		min = ( min>weight[i] ) ? weight[i] : min;
		if( compare == weight[i] )
			++biger;
	}
	cout<<"max:\t"<<max<<endl;
	cout<<"min:\t"<<min<<endl;
	cout<<"biger than "<<compare<<": "<<biger<<endl;
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?