作业帮 > 综合 > 作业

vc++编程求大神,Output Positive Numbers

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/05/30 17:37:08
vc++编程求大神,Output Positive Numbers
题目描述

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.
输入格式

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.
输出格式

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.
样例输入
3
12 13 -1
样例输出
12 13
我的程序是
#include<iostream>
#include<vector>
using namespace std;
int main()

 vector<int> list;    
 int num;  
 cin>>num;    
 int oj;
 while(num--)    
  {        
    cin>>oj; 
    cout<<" ";      
    list.push_back(oj);
  }    
 for(int k=0;k<list.size();k++)    
  {        
   if(list[k]>0)        
    {            
     cout<<list[k];        
    }        
  }
}  
不知道哪里错了
vc++编程求大神,Output Positive Numbers
百度搜孙鑫或者黄维通