第一次建项目就出错了,怎么一回事?
程序代码:
//manydice,c--多次投色子的模拟程序
//与diceroll.c一起编译
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include"diceroll.h"
int main (void)
{
int dice,roll;
int sides;
srand((unsigned int)time(0));
printf("输入每个色子的边数,0停止.");
while(scanf("%d",&sides)==1 && sides > 0)
{
printf("多少个色子?\n");
scanf("%d",&dice);
roll = roll_n_dice (dice,sides);;
printf("你使用了%d个%d面的色子滚动到了%d\n",roll,dice,sides);
printf("有多少个面,输入0停止.");
}
printf("rollem函数被调用了%d次.");
printf("祝你好运!");
return 0;
}
程序代码://diceroll.h extern int roll_count; int roll_n_dice(int dice,int sides);
程序代码:
//diceroll.c--投色子的模拟游戏
#include"diceroll.h"
#include<stdio.h>
#include<stdio.h>
int roll_count = 0;
static int rollem(int sides)
{
int roll;
roll = rand () % sides + 1;
++roll_count;
return roll;
}
int roll_n_dice(int dice,int sides)
{
int d;
int total = 0;
if(sides < 2)
{
printf("至少需要2面.\n");
return -2;
}
if(dice < 1)
{
printf("至少需要1面.\n");
return -1;
}
for(d = 0;d < dice; d++)
total += rollem(sides);
return total;
}
程序代码:
#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
return 0;
}
怎么一回事,我的int main没错啊,怎么会说我重复main?






