#include<iostream>
#include<stdlib.h>
#include<time.h>
#include<iomanip>
#include<string>
using namespace std;
void main()
{
int i,j,a[27],n1,n2,n3;
string b[54]={"a-A","a-2","a-3","a-4","a-5","a-6","a-7","a-8","a-9","a-10","a-J","a-Q","a-K","b-A","b-2","b-3","b-4","b-5","b-6","b-7","b-8","b-9","b-10","b-J","b-Q","b-K","c-A","c-2","c-3","c-4","c-5","c-6","c-7","c-8","c-9","c-10","c-J","c-Q","c-K","d-A","d-2","d-3","d-4","d-5","d-6","d-7","d-8","d-9","d-10","d-J","d-Q","d-K",
"K-1","K-2"};
srand((int)time(0));
for(i=0;i<27;i++)
label:
a[i]=rand()%54;
for(j=0;j<i;j++)
{if(a[i]==a[j])
goto label;}
if(i%9==0)cout<<endl;
cout<<setw(5)<<b[a[i]];
}
cout<<endl<<"Please remember a card,and tell me what line it reside in(1/2/3):";
label1:
cin>>n1;
if(n1!=1&&n1!=2&&n1!=3)
{cout<<"Error!Tell me again!Please input the number:";
goto label1;}
cout<<"-----------------------------------------------------------------------"<<endl;
cout<<b[a[0]]<<"  "<<b[a[1]]<<"  "<<b[a[2]]<<"  "<<b[a[9]]<<"  "<<b[a[10]]<<"  "<<b[a[11]]<<"  "<<b[a[18]]<<"  "<<b[a[19]]<<"  "<<b[a[20]]<<endl;
cout<<b[a[3]]<<"  "<<b[a[4]]<<"  "<<b[a[5]]<<"  "<<b[a[12]]<<"  "<<b[a[13]]<<"  "<<b[a[14]]<<"  "<<b[a[21]]<<"  "<<b[a[22]]<<"  "<<b[a[23]]<<endl;
cout<<b[a[6]]<<"  "<<b[a[7]]<<"  "<<b[a[8]]<<"  "<<b[a[15]]<<"  "<<b[a[16]]<<"  "<<b[a[17]]<<"  "<<b[a[24]]<<"  "<<b[a[25]]<<"  "<<b[a[26]]<<endl; 
cout<<endl<<"What line the card you remember reside in now(1/2/3):";
label2:
cin>>n2;
if(n2!=1&&n2!=2&&n2!=3)
{cout<<"Error!Tell me again!Please input the number:";
goto label2;}
cout<<"-----------------------------------------------------------------------"<<endl;
for(i=0;i<25;i=i+3)
{cout<<setw(5)<<b[a[i]];}
cout<<endl;
for(i=1;i<26;i=i+3)
{cout<<setw(5)<<b[a[i]];}
cout<<endl;
for(i=2;i<27;i=i+3)
{cout<<setw(5)<<b[a[i]];}
cout<<endl;
cout<<endl<<"What line the card you remember reside in now(1/2/3):";
label3:
cin>>n3;
do{cout<<"Error!Tell me again!Please input the number:";
goto label3;}
while(n3!=1||n3!=2||n3!=3);
cout<<"-----------------------------------------------------------------------"<<endl;
cout<<"Your remembered card is:  ";
cout<<b[a[9*n1+3*n2+n3-13]];
}
#include <stdio.h>
static char *title=" 日 一 二 三 四 五 六";
static char *month[12]={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};
static day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int week(int year);
int leap(int year);
void main()
{start:
int date[4][6][21]={0},a,b,c; 
int year,j,k,l,d=0;           
int da,db,dc;                 
printf("请输入年份:");
scanf("%d",&year);
if(leap(year)) day[1]=29;     
printf("\n%37d年",year);     
for(a=0;a<4;a++)             
d=0;
if(a==0) k=1;
else if(a==1) k=4;
else if(a==2) k=7;
else if(a==3) k=10;     
printf("\n");
for(j=0;j<3;j++){
printf("  ");
for(l=0;l<21;l++) printf("-");}
printf("\n");
for(j=k-1;j<k+2;j++){                   
d++;
if(d==1) printf("%15s",month[j]);
else printf("%23s",month[j]);}
printf("\n");     
for(j=0;j<3;j++){
printf("  ");
for(l=0;l<21;l++) printf("-");}
printf("\n");
for(j=0;j<3;j++){                         
printf("  %s",title);}
printf("\n  ");   
if(k==1) da=week(year);   
else {da=dc+day[k-2]%7; if(da>6) da=da-7;} 
db=da+day[k-1]%7; if(db>6) db=db-7;
dc=db+day[k]%7;  if(dc>6) dc=dc-7;     
b=0;c=da;
for(j=1;j<=31;j++)
{
if(j>day[k-1]) break;
if(c>6){
c=0;
b++;}
date[a][b][c]=j;
c++;
b=0;c=db+7;
for(j=1;j<=31;j++)
{
if(j>day[k]) break;
if(c>13){
c=7;
b++;}
date[a][b][c]=j;
c++;
b=0;c=dc+14;
for(j=1;j<=31;j++)
{
if(j>day[k+1]) break;
if(c>20){
c=14;
b++;}
date[a][b][c]=j;
c++;
for(b=0;b<6;b++){
for(c=0;c<=20;c++){   
if (c==7||c==14) printf("  ");   
if(date[a][b][c]!=0) printf ("%3d",date[a][b][c]);
else printf("  ");}
printf("\n  ");
} printf怎么加endl
for(j=0;j<3;j++){
for(l=0;l<21;l++) printf("-");
printf("  ");}
printf("\n");
goto start;
}
int leap(int year)           
{   
if(year%400==0) return 1;
else if(year%4==0&&year%100!=0) return 1;
else return 0;
}
int week(int year)         
{
return (year-1+(year-1)/4-(year-1)/100+(year-1)/400+1)%7;
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。