返回列表 發帖

抓取空白分隔的數字(已知數目)

本帖最後由 tonyh 於 2022-12-8 20:40 編輯

範例輸入:
12
5 0 4 0 2 6 0 8 14 0 7 1

範例輸出:
5 0 4 0 2 6 0 8 14 0 7 1
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n, data[100001];
  4. int main()
  5. {
  6.     cin.tie(0);
  7.     cin.sync_with_stdio(0);

  8.     cin>>n;

  9.     for(int i=0; i<n; i++)
  10.         cin>>data[i];

  11.     for(int i=0; i<n; i++)
  12.         cout<<data[i]<<" ";
  13.     cout<<endl;

  14.     return 0;
  15. }

  16. /*
  17. 12
  18. 5 0 4 0 2 6 0 8 14 0 7 1
  19. */
複製代碼

返回列表