#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]);
读入一个整数,而你的代码连续读了**8**个整数??? 你可以在第一行输入8个整数,记住要加空格,肯定能跑过去了。
回到这道题,**正确处理**年月日,应该读入一个整数,分别除100,10000提取出来余数。
你把int i在外面定义一下看看有一些编译器不支持这么定义可能
试一下int main(){
}
将主函数括号里的参数删掉