读取一个整数n ,它最大为25 ,然后读取n 个数的表,并且以逆序打印这个表.
来源:互联网 发布:基金模拟交易软件 编辑:程序博客网 时间:2024/06/06 01:00
#include <stack>
#include <iostream>
using namespace std;
int main()
/*Pre:The user supplies an integer n and n decimal numbers.
Post: The numbers are printed in reverse order.
Uses: The STL class stack and its methods*/
{
int n;
double item;
stack<double>numbers; // deckares and initializes a stack of numbers
cout <<"Type in a integer n followed by n decimal numbers."<<endl
<<"The numbers will be printed in reverse order."<<endl;
cin>>n;
for(int i = 0;i<n;i++)
{
cin>>item;
numbers.push(item);
}
cout<<endl<<endl;
while (!numbers.empty())
{
cout<<numbers.top()<<" ";
numbers.pop();
}
cout<<endl;
#include <iostream>
using namespace std;
int main()
/*Pre:The user supplies an integer n and n decimal numbers.
Post: The numbers are printed in reverse order.
Uses: The STL class stack and its methods*/
{
int n;
double item;
stack<double>numbers; // deckares and initializes a stack of numbers
cout <<"Type in a integer n followed by n decimal numbers."<<endl
<<"The numbers will be printed in reverse order."<<endl;
cin>>n;
for(int i = 0;i<n;i++)
{
cin>>item;
numbers.push(item);
}
cout<<endl<<endl;
while (!numbers.empty())
{
cout<<numbers.top()<<" ";
numbers.pop();
}
cout<<endl;
}
- 读取一个整数n ,它最大为25 ,然后读取n 个数的表,并且以逆序打印这个表.
- 输入一个整数,判断其是否是2^n,是就输出这个数,不是就输出和它最接近的为2^n的那个整数。
- 已知一个整数n,写一个函数f(n),返回0~n间,每个数中出现的“1”的个数,问最大的F(n)= n中n为多少
- N个整数,求其中任意N-1个数的乘积中的最大的一个
- 打印一个N*N的方阵,N为每边字符的个数( 3〈N〈20 )
- 打印一个N*N的方阵,N为每边字符的个数( 3〈N〈20 )
- N个数组成最大整数
- 输入n,然后输入n个数,使它升序输出
- 10月25日 c语言 读取7个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*
- 编写一个程序,它读取一个文件以判断其中的字节数,然后使用0覆盖所有的字节
- 8、编写一个程序,它先将键盘上输入的一个字符串转换成十进制整数, 然后打印出这个十进制整数对应的二进制形式。
- 找出N个整数中最大的K个数
- 找出N个整数中最大的K个数
- 找出N个整数中最大的K个数
- 找出N个整数中最大的K个数
- 找出N个整数中最大的K个数
- 找出N个整数中最大的K个数python
- <编程之美>给定一个十进制正整数N,写下从1开始,到N的所有整数,然后数一下其中出现的所有1的个数
- 输入一个年输出其天干地支纪年法的表达式
- samsung galaxy tab 3 t310 获取root权限
- hdu Farm Irrigation
- Config File Settings Of EF——实体框架的配置文件设置
- 巴斯卡(Pascal)三角形
- 读取一个整数n ,它最大为25 ,然后读取n 个数的表,并且以逆序打印这个表.
- Postgresql 9.1 添加用户 Ubuntu12.04
- python入门
- 关于SYS/BIOS,将中断处理放在HWI的做法
- 虎嗅: 小米盒子vs乐视盒子
- 第一章
- 宽带造成连接错误691的原因与处理办法【xpghost】
- Windows Managers vs Login Managers Vs Display Managers Vs Desktop Environment
- JBOSS ESB企业服务器总线