美文网首页
【MAC 上学习 C++】Day 60-1. 6-1 简单输出整

【MAC 上学习 C++】Day 60-1. 6-1 简单输出整

作者: RaRasa | 来源:发表于2019-10-23 20:09 被阅读0次

    6-1 简单输出整数 (10 分)

    1. 题目摘自

    https://pintia.cn/problem-sets/14/problems/733

    2. 题目内容

    本题要求实现一个函数,对给定的正整数N,打印从1到N的全部正整数。

    函数接口定义:

    void PrintN ( int N );
    其中N是用户传入的参数。该函数必须将从1到N的全部正整数顺序打印出来,每个数字占1行。

    输入样例:

    3

    输出样例:

    1
    2
    3

    3. 源码参考
    #include <iostream>
    
    using namespace std;
    
    void PrintN ( int N );
    
    int main ()
    {
        int N;
    
        cin >> N;
        PrintN( N );
    
        return 0;
    }
    
    void PrintN ( int N )
    {
      for(int i = 1; i <= N; i++)
      {
        cout << i << endl;
      }
    
      return;
    }
    
    

    相关文章

      网友评论

          本文标题:【MAC 上学习 C++】Day 60-1. 6-1 简单输出整

          本文链接:https://www.haomeiwen.com/subject/jsodmctx.html