试题编号: 201912-1
试题名称: 报数
1.报出的数是7的倍数或含有数字7直接跳过
2.统计每个人跳过次数
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std;
int main()
{
int n;
int m=1;
int a,b,c,d;
int t=0;
int te;
int f;
a=b=c=d=0;
cin>>n;
while(m<=n)
{
f=0;
te=m;
//报出的数含有数字7就另f=1
do{
t=te%10;
te=te/10;
if(t==7)
f=1;
}while(te>0);
//这里可以另外写一个判断的函数,右大小为4的数组存储玩家跳过信息,不想改了
//我写得也太垃圾了吧
if(m%4==1)
{
if(m%7==0||f)
{
a++;
n++;
}
}
else if(m%4==2)
{
if(m%7==0||f)
{
b++;
n++;
}
}
else if(m%4==3)
{
if(m%7==0||f)
{
c++;
n++;
}
}
else if(m%4==0)
{
if(m%7==0||f)
{
d++;
n++;
}
}
m++;
}
cout<<a<<endl;
cout<<b<<endl;
cout<<c<<endl;
cout<<d<<endl;
return 0;
}