C++程序设计 Output Positive Numbers
![](images/u2507.png)
C++程序设计 Output Positive Numbers
Description
Please wirte a program to read integers from the keyboard and print all the positive numbers out.Each number is in the scope of the int type.
Input
The input contains two lines.The first line is a number that indicates how much numbers to be read.Then the numbers are listed in the second line separated by white spaces.There are no more than 1000 numbers to be read.
Output
Print out all the positive numbers in one line and there should be one white space between two numbers.
Note:there should be no white space in the end of the output.
Sample Input
3
12 13 -1
Sample Output
12 13
Description
Please wirte a program to read integers from the keyboard and print all the positive numbers out.Each number is in the scope of the int type.
Input
The input contains two lines.The first line is a number that indicates how much numbers to be read.Then the numbers are listed in the second line separated by white spaces.There are no more than 1000 numbers to be read.
Output
Print out all the positive numbers in one line and there should be one white space between two numbers.
Note:there should be no white space in the end of the output.
Sample Input
3
12 13 -1
Sample Output
12 13
已提交,审核后显示!提交回复
共1条回复
florashaw11 共回答了23个问题
|采纳率95.7%- #include
using namespace std;int main(){bool isFirst = true;int totalNum, item;&nbs... - 1年前
相关推荐
- 程序设计 call by value ,call by address ,call by name
程序设计 call by value ,call by address ,call by name
假设有一段code内容大致如下:
----------------------------------
MAIN()
BEGIN
A[1:4]={1,2,3,4};
X = 1;
Y = 2;
CALL SUB(X,Y,A[X]);
END
SUB(A,B,C)
BEGIN
A = B;
C = 12;
END
----------------------------------
在下列三种呼叫方式下
程式执行的结果各为何?
希望能附上说明给我,这样我比较能理解
call by value
call by address (reference)
call by namezuixinren1年前1
-
winwinhua 共回答了15个问题
|采纳率80%call by value 方式:
调用时子程序得到的是参数值的副本,子程序中对形参的改变其实只是影响了该副本的值,但在返回主程序后该副本会被丢弃,因此在主程序中按值调用的参数仍保持原来的值.
例如SUB(A,B,C)中,若形参A是by value的,则在MAIN中CALL SUB(X,Y,A[X])后,X仍为1.
call by address/reference 方式:
调用时子程序得到的是实际参数的内存地址,因此在子程序中改变形参的值时,实际会导致对该形参所对应的地址处的内存数据的变化,即直接修改的是主程序中的变量的值,返回主程序后该参数所对应的变量值会产生变化.
例如SUB(A,B,C)中,若形参A是by reference的,则在MAIN中CALL SUB(X,Y,A[X])后,X会变为2.
call by name 方式:
有点类似于宏扩展的方式,调用的参数并非是在调用前计算出来,而是在子程序中每个引用所对应的形参的地方都重新进行计算,因此有延迟计算的作用.例如你例子中,若主程序调用SUB时是by name的,则实际执行的情况是:
A=B --> X=Y --> X=2
C=12 --> A[X]=12 --> A[2]=12
这里就看到,因为X的值先变化过,所以在对C赋值的时候,实际影响的是A[2],而不是A[1].1年前查看全部
- VF循环程序设计 DO WHILE
VF循环程序设计 DO WHILE
求 e=1+1/1!+ 1/2!+ ...+ 1/n!(要求1/n!alexandergu1年前1
-
哈哈吆 共回答了14个问题
|采纳率92.9%clear
set talk off
e=1
n=1
p=1
do while 1/p>=10^(-6)
e=e+1/p
n=n+1
p=p*n
enddo
?"e=",e
set talk on
return1年前查看全部
大家在问
- 1长方体ABCD-A1B1C1D1中,AB=1BC=2,AA1=3则点D1到直线AC的距离
- 2(2013•湘西州)如图是一同学正在体育课中进行实心球投掷训练,投出的实心球在上升过程中( )
- 3氯溴碘单质氧化性递减原因同主族元素从上到下------,得电子能力减弱
- 4wouldn't mind除了不介意的话还可以怎么理解?
- 5java编程2编写一个Java源程序(包含一个公共类),可以完成猜数游戏:(1)程序生成一个1~10之间的随机整数。(2
- 61.在标准情况下,在三个干燥烧瓶内.分别装有:甲为干燥纯净的NH3.乙为一半空气一半HCL.丙为NO2与O2体积比为4:
- 715人中选5人参赛,某3人中至少有一人入选,有几种选法
- 8反应A(g)+B(g)⇌C(g)+D(g)过程中的能量变化如图所示,回答下列问题.
- 9超声波手术刀除去结石、治癌的原理是什么
- 10p67-h67-x58-h57-h55-p55-p45-p43-g45-g41-g31 -----这个顺序对吗(从前往后
- 11第11题怎么做.
- 12为什么HAc=c-H+
- 13关于大气垂直分层说法正确的是A、闪电一般发生在平流层底 B、对飞机飞行有利的是对流层的上部C、随高度升高,气温降低的是平
- 14there were so many beautiful f____ on both sides of the road
- 15第二.三周期原子结构与元素化合价或周期数的关系