(在线等!!!)c++中输入整数的数目不知道,要怎么写输入语句?
来源:百度知道 编辑:UC知道 时间:2024/06/11 13:28:39
如:3 1 2 3(第一个数表示后面共有几个数)
int i;
cin<<i;
for(int j=0;j<i;j++)
cin>>A[j];//A是你定义的数组
int main(int argc, char** argv)
{
/// check if input parameters are effective
if(argc <= 2 || argc - 2 != argv[1])
{
System("Incorrect input! Terminate App");
return 1;
}
/// do what you wanna, here
}
e.g
sh#: a.out 3 1 2 3
#include "stdio.h"
#include <iostream>
using namespace std;
#define SIGN 10000
int main(void)
{
int i = 0;
while(scanf("%d",&i) && i != 10000)
cout << i << endl;
return 0;
}
如果是int整型,不用特意设定数目的个数,你输入数字后,系统会自动计算的如a=123,b=456789 c=a+b c=456912
while(cin>>n);