想做一个随机的抽奖程序,没有学过随机数相关,c++是自学的比较生,请问这种情况怎么解决?求帮忙!软件:Dev-c++ 5.11 编译器:TDM-GCC 4.9.2 64-bit Release
//
//
//
#include <iostream>
#include <cstdlib> // Header file needed to use srand and rand
#include <ctime> // Header file needed to use time
using namespace std;
int a=0,b=0,c=0;
a = rand() % 6;
b = rand() % 6;
c = rand() % 6;
int main()
{
if(b==a){
while(b!=a) b = rand() % 6;
}
if(c==a||c==b){
while(c!=a&&c!=b) c = rand() % 6;
}
char x[5]={'纥','风Vanhogh','阿七','ME','鸽子'}
for(int i=1;i++;i<6){
if(x[i]==x[a]) printf("无偿摇人结果%c\n",x[a]);
if(x[i]==x[b]) printf("点图摇人结果%c\n",x[b]);
if(x[i]==x[c]) printf("出设摇人结果%c\n",x[c]);
}
return 0;
}
[Warning] multi-character character constant [-Wmultichar]
[Warning] character constant too long for its type
[Error] 'a' does not name a type
[Error] 'b' does not name a type
[Error] 'c' does not name a type