📄 00027.cpp
字号:
/*
名称编号:00027
实现功能:中国福利彩票双色球兑奖程序
运行结果:通过
*/
/***************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int compare(int a1[],int a2[])
{
int n=0,h,k;
for(h=0;h<6;h++)
for(k=0;k<6;k++)
{if(a1[h]==a2[k])
n++;
}
return n;
}
void GetCase(int x,int y)
{
if(x==6&&y==1)
{ cout<<"恭喜你!"<<endl;
cout<<"一等奖"<<setw(13)<<"5,000,000"<<setw(5)<<"元"<<endl;
}
if(x==6&&y==0)
{ cout<<"恭喜你!"<<endl;
cout<<"二等奖"<<setw(13)<<"一等奖的70%"<<setw(5)<<"元"<<endl;
}
if(x==5&&y==1)
{ cout<<"恭喜你!"<<endl;
cout<<"三等奖"<<setw(13)<<"3,000"<<setw(5)<<"元"<<endl;
}
if((x==5&&y==0)||(x==4&&y==1))
{ cout<<"恭喜你!"<<endl;
cout<<"四等奖"<<setw(13)<<"200"<<setw(5)<<"元"<<endl;
}
if((x==4&&y==0)||(x==3&&y==1)||(x==2&&y==1)||(x==1&&y==1)||(x==0&&y==1))
{ cout<<"恭喜你!"<<endl;
cout<<"五等奖"<<setw(13)<<"10"<<setw(5)<<"元"<<endl;
}
if(y==0)
cout<<"!谢谢惠顾!"<<endl;
}
void main()
{int i,p,j;
char c;
int array1[7]={7,8,17,21,30,32,15};
int array2[7];//0~6这7个数。
cout<<"本期双色球中奖号码为:";
for(i=0;i<7;i++)
{cout<<array1[i]<<" ";
if(i==5) cout<<"+";
}
cout<<endl;
Loop: cout<<"请输入本期红色球号码(6个):"<<endl;
for(j=0;j<6;j++)
cin>>array2[j];
cout<<"请输入蓝色球号码:";
cin>>array2[6];
int m=0;//记住重新初始化,否则就会使m变为1而出错。
if(array2[6]==array1[6])
m=1;
p=compare(array1,array2);
GetCase(p,m);
cout<<"你想继续吗?(y/n)";
cin>>c;
if(c=='y'||c=='Y')
goto Loop;
else
cout<<"程序结束!"<<endl;
}
/***************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -