回复 楼主 undeadbird
你这个可以这样格式么? a.out 2 2 2 2 么??命令行格式
程序代码:#include<stdio.h>
#include<stdlib.h>
int main(int argv,char *argc[])
{
int temp=0;
if(argv<2)
printf("eror\n");
for(int i=1;i<argv;i++)
temp+=atoi(argc[i]);
printf("temp =%d\n",temp);
}在dos下执行 cpp1.exe 1 11 111 1111
突然想到一个方法,参考一下吧,本人也
程序代码:#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 41
int main()
{
char b[MAX];
char *p[MAX];
char *buf=b;
int temp=0;
int i=0;
printf("Input:");
gets(b);
while((p[i]=strtok(buf," "))!=NULL)
{
temp+=atoi(p[i]);
i++;
buf=NULL;
}
printf("%d\n",temp);
return 0;
}是新手[ 本帖最后由 kajj_0321 于 2013-12-2 17:07 编辑 ]

kajj->1314 努力每一天。








