注册 登录
编程论坛 C++教室

请各位看下,谢谢。

longyou2011 发布于 2011-01-22 16:41, 529 次点击
#include<iostream.h>
#include<stdio.h>
int rolldice(void);
void main()
{
    int gamestatus,sum,mypoint;
    unsigned seed;
    printf("please enter an unsigned integer:");
    printf("seed");
    strand(seed);
    sum=rolldice();
    switch(sum)
    {
        case7:
        case11:gamestatus=1;break;
        case2:
        case3:
        case12: gamestatus=2;break;
        default:
           gamestatus=0;
           mypoint=sum;
        cout<<"point is"<<my point<<endl;
         break;
        while(gamestatus==0)
        {
            sum=rolldice();
            if(sum==mypoint)
              gamepoint=1;
            else
             if(sum==7)
             gamestatus=2;
        }
        if(gamestatus==1)
          cout<<"player voins\n";
        else
          cout<<"player loses\n";
    }
    int rolldice(void)
    {
        int die1,die2,worksum;
        die1=1+rand()%6;
        die2=1+rand()%6;
        worksum=die1+die2;
        cout<<"player rolled"<<die1<<'+'<<die2<<'='<<worksum<<endl;
        return worksum;
    }
}
错在了哪里
5 回复
#2
xishui7772011-01-22 19:24
你用了随机函数,应该加上#include<time.h>
#3
xishui7772011-01-22 19:27
cout<<"point is"<<my point<<endl;
my point没有空格  
还有很多错误
#4
点线面2011-01-22 19:37
#include<iostream.h>好像没有这个,听说.h是用来区别C与C++头件,.h是C的头文件,而且没.h是C++,不过早期好像可以用.
#include<iostream>是C++

没有加useing namespace std;空间命名
#5
zhouzxijc2011-01-22 21:03
Switch语句中的case和后面的数字之间应该有空格。
#6
penwa2011-01-23 12:35
楼上说的有理
1