#include <iostream>
#include <string>
#include <cstring>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int k=0;
int a[8]={0};
int year=1;
int month=1;
int day=1;
for(int i=0;i<8;i++)
{
scanf("%d",&a[i]);
}
year=a[0];
month=a[4];
day=a[6];
for(int i=1;i<8;i++)
{
if(i<4)
{
year*=10;
year+=a[i];
}
else if(i<6)
{
month*=10;
month+=a[i];
}
else
{
day*=10;
day+=a[i];
}
}
int flag=0;
if(year>=1900&&year<=2020&&month>=1&&month<=12)
{
if(month%2) //月份为奇数
{
if(day>=1&&day<=31)
{
flag=1;
}
}
else if(month!=2&&!(month%2))
{
if(day>=1&&day<30)
{
flag=1;
}
}
else if(month==2&&year%4==0&&year%100!=0) //月份为2月闰年
{
if(day>=1&&day<=290)
{
flag=1;
}
}
else if(month==2&&!(year%4==0&&year%100!=0))
{
if(day>=1&&day<=28)
{
flag=1;
}
}
}
if(flag)
{
for(int i=0;i<8;i++)
{
k+=a[i];
}
int m=k;
int s=0;
while(k>=10)
{
m=k;
s=0;
while(m>0)
{
s+=m%10;
m/=10;
}
k=s;
}
}
else
{
cout<<"none"<<endl;
}
if(flag)
{
string str;
int n=str.length();
if(n>128)
{
cout<<"none"<<endl;
}
else
{
for(int i=0;i<n;i++)
{
if((int)str.c_str()[i]>=97&&(int)str.c_str()[i]<=122)
{
cout<<(char)((str.c_str()[i]-'a')%26+k+97);
}
else if((int)str.c_str()[i]>=65&&(int)str.c_str()[i]<=90)
{
cout<<(char)((str.c_str()[i]-'A')%26+k+65);
}
else if(str.c_str()[i]==' ')
{
cout<<"#";
}
else
{
cout<<"none";
}
}
}
}
exit(0);
return 0;
}
为什么我卡在了scanf("%d",&a[i]);?为什么连调试都卡住了,这题该怎么做?
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- greatofdream 2020-04-25 18:26关注
scanf("%d",&a[i]);
读入一个整数,而你的代码连续读了**8**个整数??? 你可以在第一行输入8个整数,记住要加空格,肯定能跑过去了。
回到这道题,**正确处理**年月日,应该读入一个整数,分别除100,10000提取出来余数。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 1
悬赏问题
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配
- ¥15 Power query添加列问题
- ¥50 Kubernetes&Fission&Eleasticsearch
- ¥15 報錯:Person is not mapped,如何解決?
- ¥15 c++头文件不能识别CDialog