C++程序设计 Output Positive Numbers
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/08/28 10:41:00
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
#include<iostream>
using namespace std;
int main()
{
bool isFirst = true;
int totalNum, item;
//读入数量
cin >> totalNum;
while(totalNum--)
{
cin >> item;
//做题只要输出和结果一致就可以了,不需要保证输入和输出分开
if (item > 0)
{
//保证输出最后没有空格
if (isFirst)
{
cout << item;
isFirst = false;
}else{
cout << " " << item;
}
}
}
cout << endl;
return 0;
}
using namespace std;
int main()
{
bool isFirst = true;
int totalNum, item;
//读入数量
cin >> totalNum;
while(totalNum--)
{
cin >> item;
//做题只要输出和结果一致就可以了,不需要保证输入和输出分开
if (item > 0)
{
//保证输出最后没有空格
if (isFirst)
{
cout << item;
isFirst = false;
}else{
cout << " " << item;
}
}
}
cout << endl;
return 0;
}
vc++编程求大神,Output Positive Numbers
positive numbers是什么意思
微积分Find two positive numbers
C程序设计 英语怎么说
数据结构程序设计(C++)
C语言中output()是什么意思
Output
Given a positive integer N,you should output the most right
【程序设计】------------------------------------------------------
positive
positive!
英语翻译How many of the first ten positive whole numbers can be