How to read in user entered comma separated integers?

后端 未结 9 538
轮回少年
轮回少年 2020-12-07 02:14

I\'m writing a program that prompts the user for:

  1. Size of array
  2. Values to be put into the array

First part is fine, I create a dynamica

9条回答
  •  时光取名叫无心
    2020-12-07 02:52

    #include 
    using namespace std;
    
    int main() {
        int x,i=0;
        char y;               //to store commas
        int arr[50];
        while(!cin.eof()){
            cin>>x>>y;
            arr[i]=x;
            i++;
        }
    
        for(int j=0;j

提交回复
热议问题