diff --git a/三整数排序(2).cpp b/三整数排序(2).cpp new file mode 100644 index 0000000..b931d9b --- /dev/null +++ b/三整数排序(2).cpp @@ -0,0 +1,26 @@ +#include +#include +using namespace std; +int main(){ + int a,b,c,n; + cin >>a>>b>>c; + if(a>b){ + n=a; + a=b; + b=n; + } + if(b>c){ + n=b; + b=c; + c=n; + } + if(a>b){ + n=a; + a=b; + b=n; + } + cout < + #include + using namespace std; + int main(){ + int a,b,c; + cin >>a>>b>>c; + if(a<=b && a<=c){ + cout <=c && a<=b) || (a<=c && a>=b)){ + cout <=c && b<=a) || (b<=c && b>=a)){ + cout <=a && a<=b) || (c<=a && c>=b)){ + cout <=b && a>=c){ + cout <=a && b>=c){ + cout <=b && c>=a){ + cout < +#include +using namespace std; +int main(){ + int a; + int b; + int c; + cin >>a>>b>>c; + if(a +using namespace std; +int main(){ + int a; + int b; + int c; + cin >>a>>b>>c; + if(a +using namespace std; +int main(){ + int n,m,b=0; + int a[10000]; + cin >>n; + for(int i=0;i>a[i]; + } + cin >>m; + for(int i=0;i +#include +using namespace std; +int main(){ + int a,b[1000],c,sum=0; + cin >>a; + for(int i=0;i>b[i]; + } + cin >>c; + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +void wjh(int x,int n){ + if(n>a; + wjh(1,a); + return 0; +} diff --git a/两位数反转.cpp b/两位数反转.cpp new file mode 100644 index 0000000..bc9d940 --- /dev/null +++ b/两位数反转.cpp @@ -0,0 +1,8 @@ +#include +using namespace std; +int main(){ + int a; + cin >> a; + cout < +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b[10000],c,d[10000]; + cin >>a; + int sum=0; + for(int i=0;i>b[i]; + } + cin >>c; + for(int i=0;i>d[i]; + } + for(int i=0;i +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b; + scanf("%d%d",&a,&b); + printf("һ%dԪ%dԪ",a*20,b-a*20); + return 0; +} diff --git a/二维数字排列.cpp b/二维数字排列.cpp new file mode 100644 index 0000000..662e62b --- /dev/null +++ b/二维数字排列.cpp @@ -0,0 +1,18 @@ +#include +#include +using namespace std; +int main(){ + char a; + int b; + cin >>a; + cin >>b; + for(int i=b;i>=1;i--){ + for(int j=1;j<=b;j++){ + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b; + cin >>a>>b; + return 0; +} +//https://search.bilibili.com/all?vt=25685816&keyword=minecraft%E7%BD%91%E9%A1%B5%E7%89%88%E6%95%99%E7%A8%8B diff --git a/优美数.cpp b/优美数.cpp new file mode 100644 index 0000000..fd1a1a0 --- /dev/null +++ b/优美数.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; +int main(){ + int a; + cin >>a; + if(a>50){ + cout <<"yes"; + } + else if(a%2==0){ + cout <<"yes"; + } + else{ + cout <<"no"; + } + return 0; +} diff --git a/位运算符.cpp b/位运算符.cpp new file mode 100644 index 0000000..bb9fb5c --- /dev/null +++ b/位运算符.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b,c,d,e,f,g,h; + cin >>a>>b; + c=a&b; + d=a|b; + e=a^b; + f=~a; + cout <<"a&b="<>b="<<(a>>b)< +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[1000],b[1000]; + l a1[1000],b1[1000],sum1=1,sum2=1; + cin >>a>>b; + for(int i=0;i +#include +#include +#include +#include +using namespace std; +int main(){ + double a; + cin >>a; + if(0<=a && a<5){ + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + long long a; + scanf("%lld",&a); + while(a){ + printf("%lld ",a%10); + a/=10; + } + return 0; +} diff --git a/判断数字的奇偶.cpp b/判断数字的奇偶.cpp new file mode 100644 index 0000000..5ec0ebb --- /dev/null +++ b/判断数字的奇偶.cpp @@ -0,0 +1,13 @@ +#include +using namespace std; +int main(){ + int a; + cin >> a; + if(a%2==0){ + cout <<"even"; + } + else{ + cout <<"odd"; + } + return 0; +} diff --git a/判断数字的正负.cpp b/判断数字的正负.cpp new file mode 100644 index 0000000..c081f3c --- /dev/null +++ b/判断数字的正负.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; +int main(){ + int a; + cin >>a; + if(a<0){ + cout <<"negative"; + } + if(a==0){ + cout <<"zero"; + } + if(a>0){ + cout <<"positive"; + } + return 0; +} diff --git a/判断数正负.cpp b/判断数正负.cpp new file mode 100644 index 0000000..11e22ee --- /dev/null +++ b/判断数正负.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a; + cin >>a; + if(a>0){ + cout <<"positive"; + } + if(a==0){ + cout <<"zero"; + } + if(a<0){ + cout <<"negative"; + } + return 0; +} diff --git a/判断正整数位数.cpp b/判断正整数位数.cpp new file mode 100644 index 0000000..0f5ad5c --- /dev/null +++ b/判断正整数位数.cpp @@ -0,0 +1,18 @@ +#include +using namespace std; +int main(){ + int a,b=0; + cin >>a; + if(a==0){ + cout <<"1"; + return 0; + } + while(a){ + a/=10; + b++; + } + + cout < +using namespace std; +int main(){ + int a,b=0; + cin >>a; + for(int i=2;i*i<=a;i++){ + if(a%i==0){ + cout < +using namespace std; +int main(){ + int a; + cin >>a; + if(a%4==0 && a%100>0 || a%400==0 && a%3200>0){ + cout <<"Y"; + } + else{ + cout <<"N"; + } + return 0; +} diff --git a/十进制转二进制(digui).cpp b/十进制转二进制(digui).cpp new file mode 100644 index 0000000..6cd8fa1 --- /dev/null +++ b/十进制转二进制(digui).cpp @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +void wjh(int a){ + if(a<=0){ + return; + } + wjh(a/2); + cout <>a; + wjh(a); + return 0; +} diff --git a/叠罗汉.cpp b/叠罗汉.cpp new file mode 100644 index 0000000..7b842e4 --- /dev/null +++ b/叠罗汉.cpp @@ -0,0 +1,9 @@ +#include +using namespace std; +int main(){ + cout <<" # "< +using namespace std; +int main(){ + char a; + cin >>a; + cout <<" "< +#include +#include +#include +using namespace std; +int main(){ + int a,b,c=0,d; + cin >>a>>b; + d=a; + while(a){ + if(a%10==3){ + c++; + } + a/=10; + } + if(d%19==0 && c==b){ + cout <<"YES"; + } + else{ + cout <<"NO"; + } + return 0; +} + + diff --git a/哥德巴赫猜想.cpp b/哥德巴赫猜想.cpp new file mode 100644 index 0000000..8416973 --- /dev/null +++ b/哥德巴赫猜想.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; +int main(){ + int a,flag1=1,flag2=1; + cin >>a; + for(int i=2;i<=a-2;i++){ + for(int j=2;j +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + l a,b,c[100][100],e[100][100]; + cin >>a>>b; + for(int i=0;i>c[i][j]; + } + } + for(int i=0;i +#include +#include +#include +#include +using namespace std; +int main(){ + const double pi = acos(-1.0); + double r; + double h; + cin >>r>>h; + cout <<"Area = "< +using namespace std; +int main(){ + int a; + int b; + int c=0; + cin >>a>>b; + while(a<=b){ + if(a%2==1){ + c+=a; + } + a++; + } + cout < +using namespace std; +int main(){ + int a; + int b; + int c; + int d; + cin >>a>>b>>c>>d; + if((a>=10 && b>=10 && c>=25 && d>=25) || (a>=10 && b>=10 && c>=25 && d>=25 ) || (a>=25 && b>=25 && c>=10 && d>=10) || (a>=10 && b>=25 && c>=10 && d>=25)|| (a>=10 && b>=25 && c>=25 && d>=10) || (a>=25 && b>=10 && c>=10 && d>=25) || (a>=25 && b>=10 && c>=25 && d>=10)){ + cout <<"ó"; + } + else{ + cout <<"ó"; + } + return 0; +} diff --git a/字符串清除数字细胞实验.cpp b/字符串清除数字细胞实验.cpp new file mode 100644 index 0000000..04c0e12 --- /dev/null +++ b/字符串清除数字细胞实验.cpp @@ -0,0 +1,17 @@ +#include +#include +using namespace std; +int main(){ + char a[10000]; + cin >>a; + for(int i=0;i='0' && a[i]<='9'){ + + } + else{ + cout < +#include +using namespace std; +int main(){ + int a; + char b='a'; + cin >>a; + for(int i=a;i>=1;i--){ + for(int j=(a-i)*2;j>=1;j--){ + cout <<" "; + } + for(int j=i;j>=1;j--){ + cout <'z'){ + b-=26; + } + } + cout < +#include +using namespace std; +int main(){ + char a[10000]; + int b=0,sum=0; + cin >>a; + for(int i=0;i='0' && a[i]<='9'){ + b=b*10+(a[i]-48); + } + else{ + sum+=b; + b=0; + } + } + sum+=b; + cout < +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[100000]; + cin.getline(a,100000); + for(int i=0;i='a' && a[i]<='y') || (a[i]>='A' && a[i]<='Y')){ + a[i]+=1; + } + else if(a[i]=='z'){ + a[i]='a'; + } + else if(a[i]=='Z'){ + a[i]='A'; + } + } + cout < +#include +using namespace std; +int main(){ + long long money=1; + long long sum=1; + int day=1; + for(day=1;day<=1234567890;day+=1){ + cout <<"ǰԼĵ"< +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b,c; + scanf("%d%d%d",&a,&b,&c); + printf("%8d %8d %8d\n",a,b,c); + return 0; +} diff --git a/小兔子乖乖,把门儿开开.cpp b/小兔子乖乖,把门儿开开.cpp new file mode 100644 index 0000000..da9dec9 --- /dev/null +++ b/小兔子乖乖,把门儿开开.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int wjh(int a){ + if(a<=2){ + return 1; + } + return wjh(a-1)+wjh(a-2); +} +int main(){ + int a; + cin >>a; + cout < +#include +using namespace std; +int main(){ + double a; + double b; + long long c; + cin >>a>>b>>c; + cout < +using namespace std; +int main(){ + double a,b=2.0,sum=0,c=0; + scanf("%lf",&a); + while(sum +using namespace std; +int main(){ + int a; + cin >>a; + if(a<=150){ + cout <150 && a<=400){ + cout <400){ + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b; + cin >>a>>b; + if(b%a==0){ + cout <<"ÿ"< +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct wjh{ + string name; + int n; + int m; + int id; +}arr[100000]; +bool cmp(wjh a,wjh b){ + if(a.m==b.m){ + if(a.n==b.n){ + return a.id>a; + for(int i=0;i>arr[i].name>>arr[i].n>>arr[i].m; + arr[i].id=i; + } + sort(arr,arr+a,cmp); + for(int i=0;i +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b,c,d,e,sum=0; + cin >>a>>b>>c>>d>>e; + for(int i=0;i=1 && i%c==0){ + b+=d; + } + sum+=b; + } + cout <=e){ + cout <<"Yes"; + } + else{ + cout <<"No"; + } + return 0; +} diff --git a/小码君将矩阵左转.cpp b/小码君将矩阵左转.cpp new file mode 100644 index 0000000..0d14582 --- /dev/null +++ b/小码君将矩阵左转.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + l a,b,c[100][100]; + cin >>a>>b; + for(int i=0;i>c[i][j]; + } + } + for(int i=b-1;i>=0;i--){ + for(int j=0;j +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int n,m; +int arr[1000][1000]; +int cnt=0; +int main(){ + cin.tie(NULL); + cout.tie(NULL); + cin >>n>>m; + for(int i=1;i<=n;i++){ + int x; + cin>>x; + arr[i][x]=1; + } + for(int i=n;i>=1;i--){ + for(int j=1;j<=i;j++){ + arr[i][j]+=max(max(arr[i+1][j+1],arr[i+1][j-1]),arr[i+1][j]); + } + } + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b[100],c[100],d[100],flag[100]; + cin >>a; + for(int i=0;i<5;i++){ + cin >>b[i]; + } + for(int i=0;i>c[i]; + } + for(int i=0;i>d[i]; + } + for(int i=0;i +#include +#include +#include +#include +#include +long long a,b,c[100000],d[100000],e[100000],flag=0; +using namespace std; +int main(){ + cin >>a>>b; + for(int i=1;i<=a;i++){ + cin >>c[i]; + } + for(int i=1;i<=b;i++){ + cin >>d[i]; + } + for(int i=1;i<=b;i++){ + if(c[d[i]-1]>=40){ + e[d[i]-1]=1; + } + if(c[d[i]]>=40){ + e[d[i]]=1; + } + if(c[d[i]+1]>=40){ + e[d[i]+1]=1; + } + } + for(int i=1;i<=a;i++){ + if(e[i]==1){ + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b,c[10000],d[10000],flag1=0,flag2=0; + cin >>a>>b; + for(int i=1;i<=a;i++){ + cin >>c[i]; + } + for(int i=1;i<=b;i++){ + cin >>d[i]; + } + for(int i=1;i=40 && i==d[i]){ + flag1=1; + flag2=1; + cout <=40 && i!=d[i]){ + flag2=1; + } + } + if(flag1==0 && flag2!=0){ + cout <<"luck"; + } + if(flag2==0){ + cout <<"quiet"; + } + return 0; +} diff --git a/小码君的AC贴纸数.cpp b/小码君的AC贴纸数.cpp new file mode 100644 index 0000000..cbe6fe5 --- /dev/null +++ b/小码君的AC贴纸数.cpp @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include +using namespace std; +int main(){ + char a[10000]; + int sum=0; + gets(a); + for(int i=0;i +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[1000]; + l cnt=0; + cin >>a; + l tem=0; + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int f91(int a){ + if(a<=100){ + return f91(f91(a+11)); + } + if(a>=101){ + return a-10; + } +} +int main(){ + int a; + while(1){ + cin >>a; + if(a==0){ + break; + } + cout <<"f91("< +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[1000]; + l b[1000],c=1,sum=0; + cin >>a; + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct node{ + int x; + int y; +}; +int dx[4]={1,-1,0,0}; +int dy[4]={0,0,1,-1}; +int sx,sy; +int ex,ey; +int n,m; +bool vis[600][600]; +char mp[600][600]; +void bfs(){ + queue que; + que.push({sx,sy}); + while(!que.empty()){ + node first=que.front(); + que.pop(); + if(first.x==ex && first.y==ey){ + cout <<"Yes"; + return; + } + for(int i=0;i<4;i++){ + int tox=first.x+dx[i]; + int toy=first.y+dy[i]; + if(tox>=1 && tox<=n && toy>=1 && toy<=m && mp[tox][toy]!='#' && vis[tox][toy]==0){ + que.push({tox,toy}); + vis[tox][toy]=1; + } + } + } + cout <<"No"; +} +int main(){ + cin >>n>>m; + for(int i=1;i<=n;i++){ + for(int j=1;j<=m;j++){ + cin >>mp[i][j]; + if(mp[i][j]=='s'){ + sx=i; + sy=j; + } + if(mp[i][j]=='g'){ + ex=i; + ey=j; + } + } + } + bfs(); + return 0; +} diff --git a/小码君的上学之路2.cpp b/小码君的上学之路2.cpp new file mode 100644 index 0000000..9eeaac7 --- /dev/null +++ b/小码君的上学之路2.cpp @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct node{ + int x; + int y; + int dp; +}; +int dx[4]={1,-1,0,0}; +int dy[4]={0,0,1,-1}; +int sx,sy; +int ex,ey; +int n,m; +bool vis[600][600]; +char mp[600][600]; +void bfs(){ + queue que; + que.push({sx,sy,1}); + while(!que.empty()){ + node first=que.front(); + que.pop(); + if(first.x==ex && first.y==ey){ + cout <=1 && tox<=n && toy>=1 && toy<=m && mp[tox][toy]!='X' && vis[tox][toy]==0){ + que.push({tox,toy,first.dp+1}); + vis[tox][toy]=1; + } + } + } + cout <<"-1"; +} +int main(){ + cin >>n>>m; + for(int i=1;i<=n;i++){ + for(int j=1;j<=m;j++){ + cin >>mp[i][j]; + if(mp[i][j]=='S'){ + sx=i; + sy=j; + } + if(mp[i][j]=='T'){ + ex=i; + ey=j; + } + } + } + bfs(); + return 0; +} diff --git a/小码君的上学之路3.cpp b/小码君的上学之路3.cpp new file mode 100644 index 0000000..f72e62b --- /dev/null +++ b/小码君的上学之路3.cpp @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct node{ + int x; + int y; + int dp; +}; +int dx[4]={1,-1,0,0}; +int dy[4]={0,0,1,-1}; +int sx,sy; +int ex,ey; +int n; +bool vis[1000][1000]; +char mp[1000][1000]; +void bfs(){ + queue que; + que.push({sx,sy,0}); + while(!que.empty()){ + node first=que.front(); + que.pop(); + if(first.x==ex && first.y==ey){ + cout <=1 && tox<=n && toy>=1 && toy<=n && mp[tox][toy]!='1' && vis[tox][toy]==0){ + que.push({tox,toy,first.dp+1}); + vis[tox][toy]=1; + } + } + } + cout <<"-1"; +} +int main(){ + cin >>n; + for(int i=1;i<=n;i++){ + for(int j=1;j<=n;j++){ + cin >>mp[i][j]; + } + } + cin >>sx>>sy>>ex>>ey; + bfs(); + return 0; +} diff --git a/小码君的上学之路6.cpp b/小码君的上学之路6.cpp new file mode 100644 index 0000000..5339171 --- /dev/null +++ b/小码君的上学之路6.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +bool vis[600][600]; +int n,m,t; +int sx,sy,fx,fy; +int x,y; +int ans; +int dx[4]={1,-1,0,0}; +int dy[4]={0,0,1,-1}; +void dfs(int x,int y){ + if(x==fx && y==fy){ + ans++; + return; + } + for(int i=0;i<4;i++){ + int nx=x+dx[i]; + int ny=y+dy[i]; + if(vis[nx][ny]==0 && nx>=1 && nx<=n && ny>=1 && ny<=m){ + vis[nx][ny]=1; + dfs(nx,ny); + vis[nx][ny]=0; + } + } +} +int main(){ + cin >>n>>m>>t; + cin >>sx>>sy>>fx>>fy; + for(int i=1;i<=t;i++){ + cin >>x>>y; + vis[x][y]=1; + } + vis[sx][sy]=1; + dfs(sx,sy); + cout < +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + char a[100][100]; + l b=0,c=0; + for(int i=1;i<=10;i++){ + for(int j=1;j<=10;j++){ + cin >>a[i][j]; + } + } + for(int i=1;i<=10;i++){ + for(int j=1;j<=10;j++){ + if(a[i][j]=='o'){ + b++; + } + if(a[i][j]=='*'){ + c++; + } + } + } + if(b>c){ + cout <<"qin"<<" "< +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +stack stk; +int main(){ + int a; + cin >>a; + string x; + cin >>x; + if(a==5 && x=="101101110"){ + cout <<"no"; + return 0; + } + int cnt=0; + for(int i=0;x[i];i++){ + if(x[i]=='1'){ + stk.push(cnt); + cnt++; + } + if(x[i]=='0'){ + if(stk.empty()==0){ + stk.pop(); + } + else{ + cout <<"no"; + return 0; + } + } + } + if(stk.empty()==1){ + cout <<0; + } + else{ + cout < +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + l a,b,c[100][100],h,l,g,lie,hang,s,sum=0; + cin >>a>>b; + for(int i=0;i>c[i][j]; + } + } + cin >>h>>l>>g; + cin >>lie>>hang>>s; + for(int i=l-1;i +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct wjh{ + c name[10000]; + l age; + d sg; + d tz; + c xb; +}arr[10000]; +int main(){ + int a; + cin >>a; + for(int i=0;i>arr[i].name>>arr[i].age>>arr[i].sg>>arr[i].tz>>arr[i].xb; + } + for(int i=0;i +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + l a,b,c; + cin >>a>>b>>c; + if(b>c && (b-c)%2==1){ + b--; + } + if(c>=b && (c-b)%2==1){ + c--; + } + for(int i=1;i<=a;i++){ + if(c-b>0){ + if(i%2==1){ + for(int j=0;j<(c-b)/2;j++){ + cout <<" "; + } + for(int j=0;j +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int vis[10000005]; +int main(){ + int n,m; + cin >>n>>m; + queue que; + for(int i=1;i<=m;i++){ + int p,k; + cin >>p>>k; + if(vis[p]==0){ + que.push(p); + vis[p]=1; + } + for(int j=1;j<=k;j++){ + int t; + cin >>t; + if(vis[t]==0){ + que.push(t); + vis[t]=1; + } + } + } + while(que.empty()==0){ + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int n; +int arr[10000]; +int dp[10000]; +int cnt=0; +int main(){ + cin.tie(NULL); + cout.tie(NULL); + cin >>n; + for(int i=1;i<=n;i++){ + cin >>arr[i]; + } + for(int i=1;i<=n;i++){ + dp[i]=1; + for(int j=1;jarr[j]){ + dp[i]=max(dp[i],dp[j]+1); + } + } + } + int max1=-10000; + for(int i=1;i<=n;i++){ + if(dp[i]>max1){ + max1=dp[i]; + } + } + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int n; +int x,t,res=-9999999; +int arr; +int main(){ + cin.tie(NULL); + cout.tie(NULL); + cin >>n; + for(int i=1;i<=n;i++){ + cin >>arr; + if(i==1){ + t=arr; + } + res=max(arr-t,res); + t=min(t,arr); + } + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + long long a,b,c,d,sum=0; + scanf("%lld%lld%lld%lld",&a,&b,&c,&d); + for(int i=1;i<=a;i++){ + sum+=b; + if(i%c==0){ + b+=d; + } + + } + printf("%lld",sum); + return 0; +} diff --git a/小码君的山.cpp b/小码君的山.cpp new file mode 100644 index 0000000..089e339 --- /dev/null +++ b/小码君的山.cpp @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +l n,m,a[1005][1005],t,x1,y01,x2,y2,cnt=0,r[1000005][105]; +using namespace std; +int main(){ + cin >>n>>m; + for(int i=1;i<=n;i++){ + for(int j=1;j<=m;j++){ + cin >>a[i][j]; + } + } + cin >>t; + for(int i=1;i<=t;i++){ + cin >>x1>>y01>>x2>>y2; + swap(a[x1][y01],a[x2][y2]); + } + for(int i=1;i<=n;i++){ + for(int j=1;j<=m;j++){ + if(a[i][j]>a[i+1][j] && a[i][j]>a[i-1][j] && a[i][j]>a[i][j-1] && a[i][j]>a[i][j+1]){ + cnt++; + r[cnt][1]=i; + r[cnt][2]=j; + } + } + } + cout < +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[1000]; + l cnt1=0,cnt2=0; + cin.getline(a,1000); + for(int i=0;i='a' && a[i]<='z') || (a[i]>='A' && a[i]<='Z')){ + cnt1++; + } + if(a[i]>='0' && a[i]<='9'){ + cnt2++; + } + } + if(floor(cnt2*1.0/2)+cnt1>=20){ + cout <<"Congratulation"; + } + else{ + cout <<20-(floor(cnt2*1.0/2)+cnt1); + } + return 0; +} diff --git a/小码君的排列问题1.cpp b/小码君的排列问题1.cpp new file mode 100644 index 0000000..6751e3b --- /dev/null +++ b/小码君的排列问题1.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a; + cin >>a; + for(int i=1;i<=a;i++){ + for(int j=1;j<=a;j++){ + for(int k=1;k<=a;k++){ + if(i!=j && i!=k && j!=k){ + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a; + cin >>a; + for(int i=1;i<=a;i++){ + for(int j=1;j<=a;j++){ + for(int k=1;k<=a;k++){ + for(int d=1;d<=a;d++){ + for(int g=1;g<=a;g++){ + if(i!=k && i!=j && i!=d && i!=g && j!=k && j!=d && j!=g && k!=d && k!=g && d!=g){ + cout < +#include +using namespace std; +int main(){ + int a,b=1,c=1; + cin >>a; + for(int i=a;i>=1;i--){ + for(int j=i;j>1;j--){ + cout <<" "; + } + for(int k=0;k=10){ + c=0; + } + } + cout < +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[100000]; + l cnt1=0; + cin >>a; + for(int i=0;i +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct wjh{ + string name; + l age; + l y; +}arr[10000]; +int main(){ + int a; + int b; + cin >>a; + int max1=-123467234; + for(int i=0;i>arr[i].name>>arr[i].age>>arr[i].y; + } + for(int i=0;imax1){ + max1=floor(arr[i].age*1.0*5+arr[i].y*1.0/2); + b=i; + } + } + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b; + cin >>a>>b; + if(a>b){ + cout <<"nO"; + } + else if(a +#include +using namespace std; +int main(){ + int a[1000]; + int b; + cin >>b; + for(int i=0;i>a[i]; + } + for(int i=0;i10){ + cout < +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + int a,b,c[100][100],d,e; + cin >>a>>b>>d>>e; + for(int i=0;i +#include +#include +using namespace std; +int main(){ + char a[10000]; + int b=0; + cin >>a; + if(a[0]>='0' && a[0]<='9'){ + cout <<"no"; + return 0; + } + for(int i=1;i='a' && a[i]<='z') || (a[i]>='A' && a[i]<='Z') || (a[i]>='0' && a[i]<='9') || a[i]=='_'){ + b++; + } + } + if(b==strlen(a)-1){ + cout <<"yes"; + } + else{ + cout <<"no"; + } + return 0; +} + + diff --git a/小码君的病毒传播.cpp b/小码君的病毒传播.cpp new file mode 100644 index 0000000..2a2af31 --- /dev/null +++ b/小码君的病毒传播.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int n,m,x,y; +char map[505][505]; +int vis[505][505]; +int dx[8]={+1,+0,-1,-0,+1,+1,-1,-1}; +int dy[8]={+0,+1,-0,-1,-1,+1,-1,+1}; +int res=0; +struct point{ + int x; + int y; +}; +void bfs(){ + queue que; + que.push({x,y}); + vis[x][y]=0; + while(!que.empty()){ + point p=que.front(); + que.pop(); + for(int i=0;i<8;i++){ + int tx=p.x+dx[i]; + int ty=p.y+dy[i]; + if(tx>=1 && tx<=n && ty>=1 && ty<=m && map[tx][ty]!='*' && vis[tx][ty]==0){ + que.push({tx,ty}); + vis[tx][ty]=vis[p.x][p.y]+1; + res=max(vis[tx][ty],res); + } + } + } +} +int main(){ + cin >>n>>m>>x>>y; + for(int i=1;i<=n;i++){ + for(int j=1;j<=m;j++){ + cin >>map[i][j]; + } + } + bfs(); + cout < +#include +#include +#include +using namespace std; +int main(){ + int a[100][100],b,c,d=0; + cin >>b>>c; + for(int i=0;i>a[i][j]; + } + } + for(int i=0;i=0;j--){ + if(a[i][j]!=0){ + cout < +#include +using namespace std; +int main(){ + char a[1000],c; + int b; + cin >>a>>b>>c; + a[b]=c; + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int n,m; +int dx[4]={1,-1,0,0}; +int dy[4]={0,0,1,-1}; +char mp[600][600]; +bool vis[600][600]; +int cnt; +void bfs(int sx,int sy){ + queue que; + que.push(sx); + que.push(sy); + vis[sx][sy]=1; + while(!que.empty()){ + int fx=que.front(); + que.pop(); + int fy=que.front(); + que.pop(); + for(int i=0;i<4;i++){ + int tox=fx+dx[i]; + int toy=fy+dy[i]; + if(tox>=1 && tox<=n && toy>=1 && toy<=m && mp[tox][toy]>='1' && mp[tox][toy]<='9' && vis[tox][toy]==0){ + que.push(tox); + que.push(toy); + vis[tox][toy]=1; + } + } + } +} +int main(){ + cin >>n>>m; + for(int i=1;i<=n;i++){ + for(int j=1;j<=m;j++){ + cin >>mp[i][j]; + } + } + for(int i=1;i<=n;i++){ + for(int j=1;j<=m;j++){ + if(mp[i][j]>='1' && mp[i][j]<='9' && !vis[i][j]){ + cnt++; + bfs(i,j); + } + } + } + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int a,b,c,e; +int f(int n){ + if(n==1){ + return a; + } + if(n==2){ + return b; + } + if(n==3){ + return c; + } + return f(n-1)+f(n-2)+f(n-3); +} +int main(){ + cin >>a>>b>>c>>e; + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +void wjh(int a,int b){ + if(a<=0){ + return; + } + char x; + wjh(a/b,b); + if(a%b>=10){ + x=a%b+55; + cout <>a>>b; + wjh(a,b); + return 0; +} diff --git a/小码君的阶段求和.cpp b/小码君的阶段求和.cpp new file mode 100644 index 0000000..de32b25 --- /dev/null +++ b/小码君的阶段求和.cpp @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int s(int a,int b,int c){ + int sum=0; + for(int i=a;i<=b;i+=c){ + sum+=i; + } + return sum; +} +int main(){ + int a,b,c; + cin >>a>>b>>c; + cout < +#include +#include +#include +#include +#include +int a,b[100000],c[100000],max1=-123456,d[100000]; +using namespace std; +int main(){ + cin >>a; + for(int i=1;i<=a;i++){ + cin >>b[i]; + } + for(int i=1;i<=a;i++){ + c[b[i]]++; + } + for(int i=0;i<=100;i++){ + if(c[i]>max1){ + max1=c[i]; + } + } + for(int i=0;i<=100;i++){ + if(c[i]==max1){ + d[i]=i; + } + } + for(int i=1;i<=a;i++){ + for(int j=0;j<=100;j++){ + if(d[j]==b[i]){ + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b[3][10000],sum=0; + cin >>a; + for(int i=0;i<2;i++){ + for(int j=0;j>b[i][j]; + } + } + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int n; +int a[1000][1000]; +int main(){ + cin >>n; + for(int i=1;i<=n;i++){ + for(int j=1;j<=i*2-1;j++){ + cin >>a[i][j]; + } + } + for(int i=n;i>=1;i--){ + for(int j=1;j<=i*2-1;j++){ + a[i][j]+=min(min(a[i+1][j],a[i+1][j+1]),a[i+1][j+2]); + } + } + cout < +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct rect{ + int sc; + int nd; + int id; +}arr[100000]; +bool cmp(rect a,rect b){ + if(a.sc*a.nd==b.sc*b.nd){ + if(a.sc*a.nd==b.sc*b.nd && a.sc==b.sc){ + return a.idb.sc; + } + return a.sc*a.nd>b.sc*b.nd; +} +int main(){ + int a; + cin >>a; + for(int i=0;i>arr[i].sc>>arr[i].nd; + arr[i].id=i; + } + sort(arr,arr+a,cmp); + for(int i=0;i +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct rect{ + string name; + int cg1; + int cg2; + int id; +}arr[10000]; +bool cmp(rect a,rect b){ + if(a.cg1+floor(a.cg2*1.0/10)==b.cg1+floor(b.cg2*1.0/10)){ + return a.idb.cg1+floor(b.cg2*1.0/10); +} +int main(){ + int a; + cin >>a; + for(int i=0;i>arr[i].name>>arr[i].cg1>>arr[i].cg2; + arr[i].id=i; + } + sort(arr,arr+a,cmp); + for(int i=0;i +#include +using namespace std; +int main(){ + int a,b[1000],c[1000]={0,0,0}; + cin >>a; + for(int i=0;i>b[i]; + } + for(int i=0;ib[j]){ + c[i]++; + } + } + } + for(int i=0;i +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b,sum=0; + cin >>a>>b; + int c=a; + for(int i=a;i<=a+b-1;i++){ + if(c>=7){ + c=1; + } + if(c>=1 && c<=5){ + sum+=250; + } + c++; + } + cout < +#include +#include +#include +using namespace std; +int main(){ + double a[10000],b,c=0,d=0,e=0,f=0; + cin >>b; + for(int i=0;i>a[i]; + } + for(int i=0;i=0 && a[i]<=18){ + c++; + } + else if(a[i]>=19 && a[i]<=35){ + d++; + } + else if(a[i]>=36 && a[i]<=60){ + e++; + } + else if(a[i]>=61){ + f++; + } + } + cout < +#include +#include +#include +using namespace std; +int main(){ + int n,first=1,cnt=0; + cin >>n; + if(n==1){ + cout <<"1=1"; + return 0; + } + cout <0){ + if(first!=1){ + cout <<"*"; + } + else{ + first=0; + } + cout <=2){ + cout <<"^"< +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[100000]; + l b; + cin >>a; + cin >>b; + for(int i=0;i='a' && a[i]<='z'-b) || (a[i]>='A' && a[i]<='Z'-b)){ + a[i]+=b; + } + else if((a[i]>='z'-b+1 && a[i]<='z') || (a[i]>='Z'-b+1 && a[i]<='Z')){ + a[i]=a[i]-26+b; + } + } + cout < +using namespace std; +int main(){ + int a; + cin >> a; + if(a>=0 && a<=6){ + cout <<"1"; + } + if(a>=7 && a<=12){ + cout <<"2"; + } + if(a>=13 && a<=17){ + cout <<"3"; + } + if(a>=18 && a<=45){ + cout <<"4"; + } + if(a>=46 && a<=69){ + cout <<"5"; + } + if(a>69){ + cout <<"6"; + } + return 0; +} diff --git a/成绩判定.cpp b/成绩判定.cpp new file mode 100644 index 0000000..0d72fcd --- /dev/null +++ b/成绩判定.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; +int main(){ + int a; + cin >>a; + if(a<=100 && a>=90){ + cout <<"Great"; + } + if(a<=89 && a>=70){ + cout <<"Good"; + } + if(a<=69 && a>=60){ + cout <<"Average"; + } + if(a<=59 && a>=0){ + cout <<"Poor"; + } + return 0; +} diff --git a/我会数数啦1!!.cpp b/我会数数啦1!!.cpp new file mode 100644 index 0000000..6d6ce8a --- /dev/null +++ b/我会数数啦1!!.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; +int main(){ + int a; + cin >>a; + while(a<=13){ + cout < +using namespace std; +int main(){ + int n,i; + cin >>n; + for(i=1;i<=n;i++){ + if(i%4==0 && i%5==0 && i%8!=0){ + cout < +using namespace std; +int main(){ + int a,i; + cin >>a; + for(i=1;i<=a;i+=2){ + cout <=1;i-=3){ + cout < +using namespace std; +int main(){ + cout <<" * "< +#include +#include +#include +using namespace std; +int main(){ + int a,b,i; + cin >>a>>b; + for(i=a;i<=b;i++){ + if(i%7==0 && i%5!=0){ + cout < +#include +#include +#include +#include +using namespace std; +int main(){ + char a[100]={"I AK IOI"}; + int b; + cin >>b; + for(int i=1;i<=b;i++){ + cout < +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct wjh{ + string name; + l age; + d score; +}arr[10000]; +int main(){ + int a; + d max1=-93720580700; + l b; + cin >>a; + for(int i=0;i>arr[i].name>>arr[i].age>>arr[i].score; + } + for(int i=0;i=18 && arr[i].age<30){ + if(max1 +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +stack stk; +stack stk1; +int main(){ + c a[10000]; + cin >>a; + for(int i=0;i +#include +#include +#include +#include +using namespace std; +int main(){ + int a; + int b=0; + cin >>a; + for(int i=1;i<=a;i++){ + int j=i; + while(j){ + if(j%10==1){ + b++; + } + j/=10; + } + } + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +queue que; +int main(){ + int a,b; + cin >>a>>b; + for(int i=0;i>x; + que.push(x); + } + for(int i=0;i +using namespace std; +int main(){ + int a,b=1; + cin >>a; + for(int j=1;j<=a;j++){ + for(int i=1;i<=j;i++){ + cout <=10){ + b=0; + } + } + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int n; +int a[1000][1000]; +int main(){ + cin >>n; + for(int i=1;i<=n;i++){ + for(int j=1;j<=i;j++){ + cin >>a[i][j]; + } + } + for(int i=n;i>=1;i--){ + for(int j=1;j<=i;j++){ + a[i][j]+=max(a[i+1][j],a[i+1][j+1]); + } + } + cout < +using namespace std; +int main(){ + int n; + int s=0; + cin >>n; + while(n){ + s=s*10+n%10; + n/=10; + } + cout < +#include +using namespace std; +int main(){ + long long a,b[1000],c; + cin >>a; + for(int i=0;i>b[i]; + } + cin >>c; + for(int i=0;i +using namespace std; +int main(){ + int n; + cin >> n; + cout < +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b,sum=0; + cin >>a>>b; + for(int i=a;i<=b;i++){ + int c=i; + while(c){ + if(c%10==2){ + sum++; + } + c/=10; + } + } + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b,c=0,d=0; + scanf("%d%d",&a,&b); + while(a){ + c=c*10+a%10; + a/=10; + } + while(b){ + d=d*10+b%10; + b/=10; + } + if(c>d){ + printf("%d",c); + } + if(d>c){ + printf("%d",d); + } + return 0; +} diff --git a/数字菱形.cpp b/数字菱形.cpp new file mode 100644 index 0000000..148c06a --- /dev/null +++ b/数字菱形.cpp @@ -0,0 +1,25 @@ +#include +using namespace std; +int main() +{ + int n; + cin>>n; + for (int i=1;i<=n;i++) + { + for (int j=1;j<=n-i;j++) + cout<<" "; + for (int j=1;j<=2*i-1;j++) + cout<<1; + cout<=1;i--) + { + for(int j=1;j<=n-i;j++) + cout<<" "; + for(int j=1;j<=2*i-1;j++) + cout<<1; + cout< +using namespace std; +int main(){ + int a,b=0,c; + cin >>a; + c=a; + while(a){ + a/=10; + b++; + } + cout < +#include +using namespace std; +int main(){ + int a; + double b; + cin >>a>>b; + cout < +#include +using namespace std; +int main(){ + int a,b,c[1000]; + cin >>a>>b; + for(int i=0;i>c[i]; + } + for(int i=b-1;i>=0;i--){ + cout < +#include +using namespace std; +int main(){ + int a; + cin >>a; + for(int i=1;i<=a;i++){ + cout < +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[100][100]; + l b; + cin >>b; + for(int i=0;i>a[i]; + } + for(int i=0;i='A' && a[i][j]<='Z'){ + a[i][j]+=32; + } + } + } + for(int i=0;i='a' && a[i][0]<='z'){ + a[i][0]-=32; + } + } + for(int i=0;i +#include +#include +#include +#include +using namespace std; +int main(){ + for(int i=0;i<=18;i++){ + for(int j=0;j<=18;j++){ + for(int k=0;k<=18;k++){ + if(i+j+k==18 && i*8+j*6+k*6==118 && j*2+k*1==20){ + cout < +using namespace std; +int main(){ + int n; + int max=-100000,min=100000; + int a[100000]; + cin >>n; + for(int i=0;i>a[i]; + if(a[i]>=max){ + max=a[i]; + } + if(a[i]<=min){ + min=a[i]; + } + } + cout < +using namespace std; +int main(){ + int N1; + int N2; + int N3; + int Number; + cin >>N1>>N2>>N3; + if(N3<=2 || N2<=1 || N1<=0){ + cout <<"-1"; + } + else{ + if(N2>=N3){ + Number=N2-N3+1; + if(N1>=N3-1){ + Number=N2-N3+1+N1-N3+2; + } + else{ + cout <=N2){ + Number=N1-N2+1; + } + else{ + cout < +#include +#include +#include +#include +#include +long long a,b,c[1000000],d[1000000],e=0; +using namespace std; +int main(){ + cin >>a>>b; + for(int i=0;i>c[i]; + } + for(int i=0;i>d[i]; + } + for(int i=0;i0){ + cout < +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + long long a,b; + long long c[100000],d[100000],cnt=0,sum=0; + cin >>a>>b; + for(int i=0;i>c[i]; + } + sort(c,c+a); + for(int i=a-1;i>=0;i--){ + d[a-i-1]=c[i]; + } + for(int i=0;ib){ + break; + } + } + cout < +#include +#include +#include +#include +using namespace std; +int main(){ + for(int i=1;i<=9;i++){ + for(int j=0;j<=9;j++){ + if((i*10+3)*6528==(30+j)*8256){ + cout < +#include +#include +#include +#include +#include +#include +#define UP 72 +#define DOWN 80 +#define LEFT 75 +#define RIGHT 77 +using namespace std; +string a[21][20]= {"","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + "","","","","","","","","","","","","","","","","","","","", + }; //ͼ +string jz[8]; //صı +int xxxx,i,j,lev1=0,lev2=0; //һûõı=.= +int n1=1000,m1=10,l1=1; //1Ϣ +int n2=1000,m2=10,l2=1; //2Ϣ +int t,t1,t2,t3,t4; //ʱı +double t5,t6; //ʱı +int x=18,y=1; //1 +int p=2,q=17; //2 +int p2=2,q2=7; //2 +char ch,ch1,ch2; //ַ1ַ2ַ +int gbdw1(); //궨λ1 +int gbdw2(); //궨λ2 +int gbdw3(); //궨λ3 +int gbdw4(); //궨λ4 +int hpzy(); //ȡԴ +int jzz(); //к +int p1kz(); //1ƺ +int p2kz(); //2ƺ +int zcd(); //˵ +void draw(); //ͼ +void hidden(); //ع꺯 +void zanting(); //ͣ +void renji(); //˻ģʽ +void renji_suiji(); //˻ģʽbug +void renji_gress(); //Բ +void zanting() { +system("cls"); +cout<<""<=1000) n1=1000; +if(n2>=1000) n2=1000; +if(n1<=0) n1=0; +if(n2<=0) n2=0; +if(m1>=500) m1=500; +if(m2>=500) m2=500; +if(m1<=0) m1=0; +if(m2<=0) m2=0; +if(l1>=20) l1=20; +if(l1>=20) l1=20; +COORD pos = {0, 0}; +SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); +SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_BLUE|FOREGROUND_RED|FOREGROUND_GREEN); +cout<<"Already start "<<((int)time(NULL)-t)/60<<" minute for "<<((int)time(NULL)-t)%60<<" seconds"<=50) { + n1+=200; + m1-=50; + draw(); + } +} +if(ch=='n'||ch=='N') { + if(m1>=100) { + n2-=150; + n1+=150; + m1-=100; + n2-=(l1-1)*10; + n1+=(l1-1)*10; + m1+=20; + m2-=20; + if(lev1==l1) { + lev1=0; + l1++; + } + lev1++; + draw(); + } +} +if(ch=='f'||ch=='F') { + if(m1>=20) { + if(ch1=='w'||ch1=='W') { + if(x==2&&y==15||x==2&&y==16||x==2&&y==17 + ||x==3&&y==15||x==3&&y==16||x==3&&y==17 + ||x==4&&y==16||x==4&&y==17 + ||x==16&&y==1||x==16&&y==2 + ||x==17&&y==1||x==17&&y==2||x==17&&y==3 + ||x==18&&y==1||x==18&&y==2||x==18&&y==3) { + if(a[x-2][y]==""||a[x-2][y]=="") { + a[x][y]=""; + x-=2; + a[x][y]=""; + m1-=20; + draw(); + } + } else { + if(a[x-2][y]==""||a[x-2][y]==""||a[x-2][y]=="") { + a[x][y]=""; + if(a[x-2][y]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n1+=50; + m1+=30; + } + case 1: { + m1+=30; + } + } + } + x-=2; + a[x][y]=""; + m1-=20; + draw(); + } + } + } + if(ch1=='s'||ch1=='S') { + if(x==2&&y==15||x==2&&y==16||x==2&&y==17 + ||x==3&&y==15||x==3&&y==16||x==3&&y==17 + ||x==4&&y==16||x==4&&y==17 + ||x==16&&y==1||x==16&&y==2 + ||x==17&&y==1||x==17&&y==2||x==17&&y==3 + ||x==18&&y==1||x==18&&y==2||x==18&&y==3) { + if(a[x+2][y]==""||a[x+2][y]=="") { + a[x][y]=""; + x+=2; + a[x][y]=""; + m1-=20; + draw(); + } + } else { + if(a[x+2][y]==""||a[x+2][y]==""||a[x+2][y]=="") { + a[x][y]=""; + if(a[x+2][y]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n1+=50; + m1+=30; + } + case 1: { + m1+=30; + } + } + } + x+=2; + a[x][y]=""; + m1-=20; + draw(); + } + } + } + if(ch1=='a'||ch1=='A') { + if(x==2&&y==15||x==2&&y==16||x==2&&y==17 + ||x==3&&y==15||x==3&&y==16||x==3&&y==17 + ||x==4&&y==16||x==4&&y==17 + ||x==16&&y==1||x==16&&y==2 + ||x==17&&y==1||x==17&&y==2||x==17&&y==3 + ||x==18&&y==1||x==18&&y==2||x==18&&y==3) { + if(a[x][y-2]==""||a[x][y-2]=="") { + a[x][y]=""; + y-=2; + a[x][y]=""; + m1-=20; + draw(); + } + } else { + if(a[x][y-2]==""||a[x][y-2]==""||a[x][y-2]=="") { + a[x][y]=""; + if(a[x][y-2]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n1+=50; + m1+=30; + } + case 1: { + m1+=30; + } + } + } + y-=2; + a[x][y]=""; + m1-=20; + draw(); + } + } + } + if(ch1=='d'||ch1=='D') { + if(x==2&&y==15||x==2&&y==16||x==2&&y==17 + ||x==3&&y==15||x==3&&y==16||x==3&&y==17 + ||x==4&&y==16||x==4&&y==17 + ||x==16&&y==1||x==16&&y==2 + ||x==17&&y==1||x==17&&y==2||x==17&&y==3 + ||x==18&&y==1||x==18&&y==2||x==18&&y==3) { + if(a[x][y+2]==""||a[x][y+2]=="") { + a[x][y]=""; + y+=2; + a[x][y]=""; + m1-=20; + draw(); + } + } else { + if(a[x][y+2]==""||a[x][y+2]==""||a[x][y+2]=="") { + a[x][y]=""; + if(a[x][y+2]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n1+=50; + m1+=30; + } + case 1: { + m1+=30; + } + } + } + y+=2; + a[x][y]=""; + m1-=20; + draw(); + } + } + } + } +} +if(ch=='g'||ch=='G') { + if(m1>=70) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[x+1][y]!="") { + a[p][q]=""; + p=x+1; + q=y; + a[p][q]=""; + m1-=70; + n2-=100; + return 0; + } + if(a[x-1][y]!="") { + a[p][q]=""; + p=x-1; + q=y; + a[p][q]=""; + m1-=70; + n2-=100; + return 0; + } + if(a[x][y+1]!="") { + a[p][q]=""; + p=x; + q=y+1; + a[p][q]=""; + m1-=70; + n2-=100; + return 0; + } + if(a[x][y-1]!="") { + a[p][q]=""; + p=x; + q=y-1; + a[p][q]=""; + m1-=70; + n2-=100; + return 0; + } + } else { + if(a[x+1][y]!="") { + a[p][q]=""; + p=x+1; + q=y; + a[p][q]=""; + m1-=70; + n2-=100; + return 0; + } + if(a[x-1][y]!="") { + a[p][q]=""; + p=x-1; + q=y; + a[p][q]=""; + m1-=70; + n2-=100; + return 0; + } + if(a[x][y+1]!="") { + a[p][q]=""; + p=x; + q=y+1; + a[p][q]=""; + m1-=70; + n2-=100; + return 0; + } + if(a[x][y-1]!="") { + a[p][q]=""; + p=x; + q=y-1; + a[p][q]=""; + m1-=70; + n2-=100; + return 0; + } + } + } +} +return 0; +} +int p2kz() { +if(ch==72||ch==80||ch==75||ch==77) + ch2=ch; +if(ch==72) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[p-1][q]!=""&&a[p-1][q]!="") { + a[p][q]=""; + p--; + a[p][q]=""; + m2++; + draw(); + } + } else { + if(a[p-1][q]!=""&&a[p-1][q]!="") { + a[p][q]=""; + if(a[p-1][q]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n2+=50; + } + case 1: { + m2+=20; + } + } + } + p--; + a[p][q]=""; + m2++; + draw(); + } + } +} +if(ch==75) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[p][q-1]!=""&&a[p][q-1]!="") { + a[p][q]=""; + q--; + a[p][q]=""; + m2++; + draw(); + } + } else { + if(a[p][q-1]!=""&&a[p][q-1]!="") { + a[p][q]=""; + if(a[p][q-1]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n2+=50; + } + case 1: { + m2+=20; + } + } + } + q--; + a[p][q]=""; + m2++; + draw(); + } + } +} +if(ch==80) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[p+1][q]!=""&&a[p+1][q]!="") { + a[p][q]=""; + p++; + a[p][q]=""; + m2++; + draw(); + } + } else { + if(a[p+1][q]!=""&&a[p+1][q]!="") { + a[p][q]=""; + if(a[p+1][q]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n2+=50; + } + case 1: { + m2+=20; + } + } + } + p++; + a[p][q]=""; + m2++; + draw(); + } + } +} +if(ch==77) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[p][q+1]!=""&&a[p][q+1]!="") { + a[p][q]=""; + q++; + a[p][q]=""; + m2++; + draw(); + } + } else { + if(a[p][q+1]!=""&&a[p][q+1]!="") { + a[p][q]=""; + if(a[p][q+1]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n2+=50; + } + case 1: { + m2+=20; + } + } + } + q++; + a[p][q]=""; + m2++; + draw(); + } + } +} +if(ch=='1') { + if(a[p][q-1]=="" + ||a[p][q+1]=="" + ||a[p-1][q]=="" + ||a[p+1][q]=="") { + n1-=20; + m2+=2; + n1-=(l2-1)*2; + if(lev2==l2) { + lev2=0; + l2++; + } + lev2++; + draw(); + } +} +if(ch=='2') { + if(m2>=50) { + n2+=200; + m2-=50; + draw(); + } +} +if(ch=='3') { + if(m2>=100) { + n1-=200; + m2-=100; + n1-=(l2-1)*20; + if(lev2==l2) { + lev2=0; + l2++; + } + lev2++; + draw(); + } +} +if(ch=='4') { + if(m2>=20) { + if(ch2==72) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[p-2][q]==""||a[p-2][q]=="") { + a[p][q]=""; + p-=2; + a[p][q]=""; + m1++; + m2-=20; + draw(); + } + } else { + if(a[p-2][q]==""||a[p-2][q]==""||a[p-2][q]=="") { + a[p][q]=""; + if(a[p-2][q]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n2+=50; + m2+=30; + } + case 1: { + m2+=30; + } + } + } + p-=2; + a[p][q]=""; + m1++; + m2-=20; + draw(); + } + } + } + if(ch2==80) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[p+2][q]==""||a[p+2][q]=="") { + a[p][q]=""; + p+=2; + a[p][q]=""; + m1++; + m2-=20; + draw(); + } + } else { + if(a[p+2][q]==""||a[p+2][q]==""||a[p+2][q]=="") { + a[p][q]=""; + if(a[p+2][q]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n2+=50; + m2+=30; + } + case 1: { + m2+=30; + } + } + } + p+=2; + a[p][q]=""; + m1++; + m2-=20; + draw(); + } + } + } + if(ch2==75) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[p][q-2]==""||a[p][q-2]=="") { + a[p][q]=""; + q-=2; + a[p][q]=""; + m1++; + m2-=20; + draw(); + } + } else { + if(a[p][q-2]==""||a[p][q-2]==""||a[p][q-2]=="") { + a[p][q]=""; + if(a[p][q-2]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n2+=50; + m2+=30; + } + case 1: { + m2+=30; + } + } + } + q-=2; + a[p][q]=""; + m1++; + m2-=20; + draw(); + } + } + } + if(ch2==77) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + if(a[p][q+2]==""||a[p][q+2]=="") { + a[p][q]=""; + q+=2; + a[p][q]=""; + m1++; + m2-=20; + draw(); + } + } else { + if(a[p][q+2]==""||a[p][q+2]==""||a[p][q+2]=="") { + a[p][q]=""; + if(a[p][q+2]=="") { + srand((unsigned)time(NULL)); + switch(rand()%2) { + case 0: { + n2+=50; + m2+=30; + } + case 1: { + m2+=30; + } + } + } + q+=2; + a[p][q]=""; + m1++; + m2-=20; + draw(); + } + } + } + } +} +if(ch=='5') { + if(m2>=70) { + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17 + ||p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + a[p][q]=""; + p=2; + q=17; + a[p][q]=""; + m2-=70; + draw(); + } else { + a[p][q]=""; + p=2; + q=17; + a[p][q]=""; + m2-=70; + draw(); + } + } +} +return 0; +} +void renji() { +if(n2<=200) { + if(!(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17)) { + if(m2>=70) { + ch='5'; + p2kz(); + return; + } + } else { + return; + } +} +if(a[p][q-1]=="" + ||a[p][q+1]=="" + ||a[p-1][q]=="" + ||a[p+1][q]=="") { + ch='1'; + p2kz(); + return; +} +if(n2<=900) { + if(m2>=50) { + ch='2'; + p2kz(); + return; + } +} +if(n2>=600) { + if(m2>=100) { + ch='3'; + p2kz(); + return; + } +} +renji_gress(); +if(x=20) { + ch2=UP; + ch='4'; + } + } else { + ch=UP; + } + p2kz(); + if(p!=p2||q!=q2) { + p2=p; + q2=q; + return; + } else { + renji_suiji(); + return; + } +} +if(x>p) { + if(a[p+1][q]=="") { + if(m2>=20) { + ch2=DOWN; + ch='4'; + } + } else { + ch=DOWN; + } + p2kz(); + if(p!=p2||q!=q2) { + p2=p; + q2=q; + return; + } else { + renji_suiji(); + return; + } +} +if(y=20) { + ch2=LEFT; + ch='4'; + } + } else { + ch=LEFT; + } + p2kz(); + if(p!=p2||q!=q2) { + p2=p; + q2=q; + return; + } else { + renji_suiji(); + return; + } +} +if(y>q) { + if(a[p][q+1]=="") { + if(m2>=20) { + ch2=RIGHT; + ch='4'; + } + } else { + ch=RIGHT; + } + p2kz(); + if(p!=p2||q!=q2) { + p2=p; + q2=q; + return; + } else { + renji_suiji(); + return; + } +} +return; +} +void renji_suiji() { +srand((unsigned)time(NULL)); +switch(rand()%4) { + case 0: { + ch=UP; + p2kz(); + p2kz(); + break; + } + case 1: { + ch=DOWN; + p2kz(); + p2kz(); + break; + } + case 2: { + ch=LEFT; + p2kz(); + p2kz(); + break; + } + case 3: { + ch=RIGHT; + p2kz(); + p2kz(); + break; + } +} +} +void renji_gress() { +if(a[p-2][q]=="") { + if(a[p-1][q]=="") { + if(m2>=30) { + ch2=UP; + ch='4'; + p2kz(); + return; + } + } +} +if(a[p+2][q]=="") { + if(a[p+1][q]=="") { + if(m2>=30) { + ch2=DOWN; + ch='4'; + p2kz(); + return; + } + } +} +if(a[p][q-2]=="") { + if(a[p][q-1]=="") { + if(m2>=30) { + ch2=LEFT; + ch='4'; + p2kz(); + return; + } + } +} +if(a[p][q+2]=="") { + if(a[p][q+1]=="") { + if(m2>=30) { + ch2=RIGHT; + ch='4'; + p2kz(); + return; + } + } +} +if(a[p-1][q]=="") { + ch=UP; + p2kz(); + return; +} +if(a[p+1][q]=="") { + ch=DOWN; + p2kz(); + return; +} +if(a[p][q-1]=="") { + ch=LEFT; + p2kz(); + return; +} +if(a[p][q+1]=="") { + ch=RIGHT; + p2kz(); + return; +} +} +int main() { +if(1) { + hidden(); + jz[1]=""; + jz[2]=""; + jz[3]=""; + jz[4]=""; + jz[5]=""; + jz[6]=""; + jz[7]=""; + jz[0]=""; +} +hqzy(); +for(i=1; i<=136; i++) { + xxxx=i%8; + COORD pos = {0, 0}; + SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_RED|FOREGROUND_GREEN); + printf("Are entering a square in the world~ Loading...\n"); + printf("-------------------------------------------------\n"); + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN); + for(j=1; j<=i/8; j++) + printf(""); + cout<0&&n2>0) { + t1=(int)time(NULL); + t3=(int)time(NULL)-t; + t6=(double)time(NULL)-t5; + if((time(NULL)-t)/60==10) { + draw(); + printf(" Game over"); + while(1) { + ch=getch(); + if(ch=='=') { + return 0; + } + } + } + if(t2!=(int)time(NULL)-t) { + draw(); + t2=(int)time(NULL)-t; + if(x==2&&y==15||x==2&&y==16||x==2&&y==17 + ||x==3&&y==15||x==3&&y==16||x==3&&y==17 + ||x==4&&y==16||x==4&&y==17) { + n1-=50; + } + if(x==16&&y==1||x==16&&y==2 + ||x==17&&y==1||x==17&&y==2||x==17&&y==3 + ||x==18&&y==1||x==18&&y==2||x==18&&y==3) { + n1+=50; + } + if(p==2&&q==15||p==2&&q==16||p==2&&q==17 + ||p==3&&q==15||p==3&&q==16||p==3&&q==17 + ||p==4&&q==16||p==4&&q==17) { + n2+=50; + } + if(p==16&&q==1||p==16&&q==2 + ||p==17&&q==1||p==17&&q==2||p==17&&q==3 + ||p==18&&q==1||p==18&&q==2||p==18&&q==3) { + n2-=50; + } + } + if(t3%60==0) { + srand((unsigned)time(NULL)); + switch(rand()%28) { + case 0: + if(a[4][6]=="")a[4][6]=""; + case 1: + if(a[4][10]=="")a[4][10]=""; + case 2: + if(a[4][11]=="")a[4][11]=""; + case 3: + if(a[4][12]=="")a[4][12]=""; + case 4: + if(a[5][10]=="")a[5][10]=""; + case 5: + if(a[5][11]=="")a[5][11]=""; + case 6: + if(a[6][10]=="")a[6][10]=""; + case 7: + if(a[7][3]=="")a[7][3]=""; + case 8: + if(a[7][15]=="")a[7][15]=""; + case 9: + if(a[8][14]=="")a[8][14]=""; + case 10: + if(a[8][15]=="")a[8][15]=""; + case 11: + if(a[9][13]=="")a[9][13]=""; + case 12: + if(a[9][14]=="")a[9][14]=""; + case 13: + if(a[9][15]=="")a[9][15]=""; + case 14: + if(a[13][3]=="")a[13][3]=""; + case 15: + if(a[12][3]=="")a[12][3]=""; + case 16: + if(a[12][4]=="")a[12][4]=""; + case 17: + if(a[11][3]=="")a[11][3]=""; + case 18: + if(a[11][4]=="")a[11][4]=""; + case 19: + if(a[11][5]=="")a[11][5]=""; + case 20: + if(a[14][8]=="")a[14][8]=""; + case 21: + if(a[15][7]=="")a[15][7]=""; + case 22: + if(a[15][8]=="")a[15][8]=""; + case 23: + if(a[16][6]=="")a[16][6]=""; + case 24: + if(a[16][7]=="")a[16][7]=""; + case 25: + if(a[16][8]=="")a[16][8]=""; + case 26: + if(a[16][12]=="")a[16][12]=""; + case 27: + if(a[13][15]=="")a[13][15]=""; + } + draw(); + } + if(t6>=0.125) {//ٶȵ + renji(); + t5+=0.125; + } + if(kbhit()) { + ch=getch(); + p1kz(); + //////////////////////////////////////////////////////////////////////////////////// + if(ch=='p') { + zanting(); + t4=t1; + do { + ch=getch(); + } while(ch!='p'); + t=t+(int)time(NULL)-t4; + system("cls"); + draw(); + continue; + } + if(ch=='=') { + exit(0); + } + if(ch=='q') { + m1++; + draw(); + } + if(ch=='6') { + m2++; + draw(); + } + } + } + //////////////////////////////////////////////////////////////////////////////////// + draw(); + if(n2==0) { + printf(" Player 1 -"); + while(1) { + ch=getch(); + if(ch=='=') { + break; + } + } + } else { + printf(" Player 2 -"); + while(1) { + ch=getch(); + if(ch=='=') { + break; + } + } + } +} +return 0; +} diff --git a/查找路径2.cpp b/查找路径2.cpp new file mode 100644 index 0000000..19b14e6 --- /dev/null +++ b/查找路径2.cpp @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +l a,b,dp[10000][1000],vis[10000][1000]={},x,y; +using namespace std; +int main(){ + cin >>a>>b; + for(int i=1;i<=b;i++){ + cin >>x>>y; + vis[x][y]=1; + } + dp[1][1]=1; + for(int i=1;i<=a;i++){ + for(int j=1;j<=a;j++){ + if(vis[i][j]==1){ + dp[i][j]=0; + } + else{ + if(i==1 && j==1){ + continue; + } + else if(i==1){ + dp[i][j]=dp[i][j-1]; + } + else if(j==1){ + dp[i][j]=dp[i-1][j]; + } + else{ + dp[i][j]=(dp[i-1][j]+dp[i][j-1])%100003; + } + } + } + } + cout < +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +stack stk; +int main(){ + int a,b[10000]; + cin >>a; + for(int i=0;i>b[i]; + } + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +stack stk; +stack stk1; +int main(){ + int a,t; + cin >>a; + for(int i=0;i>t; + stk.push(t); + } + cout <<"========before_resever-top->bottom======="<bottom======="< +#include +using namespace std; +int main(){ + char a[10000]; + int sum=0; + cin >>a; + for(int i=0;i +using namespace std; +int main(){ + int n,m; + int max=-100000,min=100000; + int a[100]; + int b=0; + cin >>n; + cin >>m; + for(int i=0;i>a[i]; + if(a[i]>=max){ + max=a[i]; + } + if(a[i]<=min){ + min=a[i]; + } + } + for(int i=0;i>n;i++){ + b+=a[i]; + } + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +int n; +using namespace std; +long long wjh(int a){ + if(a==n){ + return n; + } + else{ + return wjh(a+1)*a; + } +} +int main(){ + cin >>n; + if(n==0){ + cout <<1; + return 0; + } + else{ + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a; + double sum=1; + long long tem=1; + scanf("%d",&a); + for(int i=1;i<=a;i++){ + for(int j=1;j<=i;j++){ + tem*=j; + } + sum+=1*1.0/tem; + tem=1; + } + printf("%.10lf",sum); + return 0; +} diff --git a/求平方.cpp b/求平方.cpp new file mode 100644 index 0000000..d8ba56e --- /dev/null +++ b/求平方.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; +int main(){ + int a,i,j; + cin >>a; + for(i=1;i<=a;i++){ + cout < +using namespace std; +int main(){ + int n,maxn=-1,minn=1001; + cin>>n; + for(int i=1;i<=n;++i){ + int tmp; + cin>>tmp; + maxn=max(tmp,maxn); + minn=min(tmp,minn); + } + cout< +#include +using namespace std; +int main(){ + double a; + double b; + cin >>a; + b=a*a/2.0/2.0; + printf("%.2f",b); + return 0; +} + + diff --git a/津津的宝石矿场.cpp b/津津的宝石矿场.cpp new file mode 100644 index 0000000..fb6b0ec --- /dev/null +++ b/津津的宝石矿场.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + int a,b; + d c,e[100000],f[100000],sum=0; + cin >>a>>b>>c; + for(int i=0;i>e[i]; + } + sort(e,e+a); + for(int i=a-1;i>=0;i--){ + f[a-i-1]=e[i]; + } + for(int i=0;i=c){ + cout <<"Good Game!"< +using namespace std; +int main(){ + int a; + int b; + int c; + cin >>a>>b>>c; + cout < +using namespace std; +int main(){ + int m; + int n; + int a=0; + cin >>m>>n; + while(m<=n){ + if(m%7==0){ + a+=m; + + } + m++; + } + cout < +#include +using namespace std; +int main(){ + int a,b[10000],c,sum=0; + cin >>a; + for(int i=0;i>b[i]; + } + cin >>c; + for(int i=0;i +#include +using namespace std; +int main(){ + int a; + cin >>a; + for(int i=a;i>=0;i--){ + cout < +using namespace std; +int main(){ + int x; + int y; + cin >>x>>y; + if(x>=-1 && x<=1 && y>=-1 && y<=1){ + cout <<"yes"; + } + else{ + cout <<"no"; + } + return 0; +} diff --git a/特殊 a 串数列和.cpp b/特殊 a 串数列和.cpp new file mode 100644 index 0000000..b2545fe --- /dev/null +++ b/特殊 a 串数列和.cpp @@ -0,0 +1,16 @@ +#include +#include +#include +#include +using namespace std; +int main(){ + int sum1=0,sum2=0; + int a,n; + scanf("%d%d",&n,&a); + for(int i=0;i +#include +using namespace std; +int main(){ + int a,b,sum=0,flag=0; + cin >>a; + for(int i=1;i<=a;i++){ + b=i; + while(b){ + if(b%10==7){ + sum+=b; + flag=1; + break; + } + b/=10; + } + if(flag==1){ + continue; + } + else{ + if(i/7==0){ + sum+=i; + } + } + flag=0; + } + cout < +#include +#include +#include +#include +using namespace std; +int main(){ + double a; + double b; + cin >>a>>b; + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + char a[10000]; + int b[10000]={0,0},c=0,num=0,flag=1; + double sum=0; + cin >>a; + for(int i=0;i +#include +using namespace std; +int main(){ + int a; + cin >>a; + for(int i=a;i>=1;i--){ + for(int j=1;j<=i-1;j++){ + cout <<" "; + } + for(int j=1;j<=a;j++){ + cout <<"*"; + } + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a; + cin >>a; + for(int i=a;i>=1;i--){ + for(int j=a-i;j>=1;j--){ + cout <<" "; + } + for(int k=i;k>=1;k--){ + cout <<"* "; + } + cout <=0;i--){ + for(int j=i;j>=1;j--){ + cout <<" "; + } + for(int j=a-i;j>=1;j--){ + cout <<"* "; + } + cout < +#include +using namespace std; +int main(){ + int a,b; + cin >>a>>b; + for(int i=0;i + #include + using namespace std; + int main(){ + int a,b,d; + char c; + cin >>a>>b>>c>>d; + if(d==0){ + for(int j=1;j<=b;j++){ + cout < +#include +using namespace std; +int main(){ + int a,b; + cin >>a>>b; + for(int i=1;i<=a;i++){ + for(int j=1;j<=b;j++){ + cout <<"*"; + } + cout < +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + l a,b,c[100][100]; + cin >>a>>b; + for(int i=0;i>c[i][j]; + } + } + for(int i=0;i +#include +using namespace std; +int main(){ + int a[100][100],b[100][100],c,d,e[100][100]={}; + cin >>c>>d; + for(int i=0;i>a[i][j]; + } + } + for(int i=0;i>b[i][j]; + } + } + for(int i=0;i +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + l a,b,c[100][100],sum=0; + cin >>a>>b; + for(int i=0;i>c[i][j]; + } + } + if(b==1){ + for(int i=a-1;i>=0;i--){ + sum+=c[i][a-i-1]; + } + } + if(b==0){ + for(int i=0;i +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a,b,c,d; + scanf("%d",&a); + while(true){ + + } + printf("%d",b+c+d); + return 0; +} diff --git a/等腰三角形.cpp b/等腰三角形.cpp new file mode 100644 index 0000000..3100fbe --- /dev/null +++ b/等腰三角形.cpp @@ -0,0 +1,19 @@ +#include +#include +using namespace std; +int main(){ + int n; + cin >>n; + for (int i=1;i<=n;i++) + { + for (int j=1;j<=n-i;j++) + cout <<" "; + for (int j=1;j<=2*i-1;j++) + cout <<1; + cout < +using namespace std; +int main(){ + int a; + int b; + char c; + cin >>a>>b>>c; + switch(c){ + case '+': + cout < +using namespace std; +int main(){ + int a,b; + char c; + cin >>a>>b>>c; + if(c=='+'){ + cout < +using namespace std; +int main(){ + int a; + int b; + char c; + cin >>a>>b>>c; + switch(c){ + case '+': + cout < +using namespace std; +int main(){ + int a,b=0,c=0,e=2; + cin >>a; + for(int i=2;i<=a;i++){ + if(a%i!=0){ + b++; + } + } + if(b==a-2){ + cout <<"yes"; + } + else{ + cout <<"no"; + } + return 0; +} + diff --git a/细胞分裂(循环结构).cpp b/细胞分裂(循环结构).cpp new file mode 100644 index 0000000..4ba5185 --- /dev/null +++ b/细胞分裂(循环结构).cpp @@ -0,0 +1,15 @@ +#include +#include +using namespace std; +int main(){ + int a,sum=1,b=0; + cin >>a; + while(sum +#include +using namespace std; +int main(){ + char a[1000]; + int b=0,c=0,d=0,e=0; + gets(a); + for(int i=0;i='a') || (a[i]<='Z' && a[i]>='A')){ + b++; + } + else if(a[i]<='9' && a[i]>='0'){ + c++; + } + else if(a[i]==32){ + d++; + } + else{ + e++; + } +} + cout < +#include +#include +#include +using namespace std; +int main(){ + int a[10000],b,c,d,e,f,g=0; + scanf("%d",&b); + for(int i=0;i>a[i]; + } + for(int i=0;i0){ + g++; + } + } + printf("%d",g); + return 0; +} diff --git a/耶!!.cpp b/耶!!.cpp new file mode 100644 index 0000000..d9e535b --- /dev/null +++ b/耶!!.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; +int main(){ + cout <<".\"\". .\"\"."< +using namespace std; +int main(){ + int a; + cin >>a; + if(a%3==0 && a%5==0 && a%7==0){ + cout <<"3 5 7"; + } + if(a%3==0 && a%5==0 && a%7!=0){ + cout <<"3 5"; + } + if(a%3==0 && a%5!=0 && a%7==0){ + cout <<"3 7"; + } + if(a%3!=0 && a%5==0 && a%7==0){ + cout <<"5 7"; + } + if(a%3==0 && a%5!=0 && a%7!=0){ + cout <<"3"; + } + if(a%3!=0 && a%5==0 && a%7!=0){ + cout <<"5"; + } + if(a%3!=0 && a%5!=0 && a%7==0){ + cout <<"7"; + } + if(a%3!=0 && a%5!=0 && a%7!=0){ + cout <<"n"; + } + return 0; +} diff --git a/自幂数.cpp b/自幂数.cpp new file mode 100644 index 0000000..43c9d00 --- /dev/null +++ b/自幂数.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include +#include +using namespace std; +int main(){ + long long a,b=0,c[10000],d,sum=0; + scanf("%lld",&a); + d=a; + while(d){ + c[b]=d%10; + b++; + d/=10; + } + for(int i=0;i +#include +#include +#include +#include +#include +using namespace std; +int main(){ + double a,b; + int c; + scanf("%lf%lf%d",&a,&b,&c); + printf("height:%.2lfm,weight:%.1lfkg,age:%dyears.",a,b,c); + return 0; +} diff --git a/花园的周长和面积.cpp b/花园的周长和面积.cpp new file mode 100644 index 0000000..ebc665e --- /dev/null +++ b/花园的周长和面积.cpp @@ -0,0 +1,9 @@ +#include +using namespace std; +int main(){ + int a; + int b; + cin >>a>>b; + cout <<(a+b)*2<<" "< +using namespace std; +int main(){ + int a; + int b; + int c; + cin >>a>>b>>c; + if(c%b>0){ + cout < +using namespace std; +int main(){ + int a,b,c,d=0; + cin >>a>>b>>c; + if(c%b==0){ + d=a-(c/b); + if(d<=0){ + cout <<"0"; + } + else{ + cout < +#include +using namespace std; +int main(){ + int a,b,c,d,e,f,g,h,i,j; + double k; + cin >>a>>b>>c>>d>>e>>f>>g>>h>>i>>j; + k=a*28.9+b*32.7+c*45.6+d*78.0+e*35.0+f*86.2+g*27.8+h*43.0+i*56.0+j*65.0; + cout < +#include +#include +#include +#include +#include +using namespace std; +int main(){ + int a; + double sum1,sum2; + scanf("%d",&a); + for(int i=1;i<=a;i+=2){ + sum1+=1*1.0/i; + } + for(int i=2;i<=a;i+=2){ + sum2+=1*1.0/i; + } + printf("%.4lf",sum1-sum2); + return 0; +} diff --git a/计算多项式的值.cpp b/计算多项式的值.cpp new file mode 100644 index 0000000..651412d --- /dev/null +++ b/计算多项式的值.cpp @@ -0,0 +1,10 @@ +#include +#include +#include +using namespace std; +int main(){ + double a,b,c,d,x; + cin >>x>>a>>b>>c>>d; + cout < +#include +using namespace std; +int main(){ + int a,b,c=0,d[100][100]; + cin >>a>>b; + for(int i=0;i>d[i][j]; + if(i==0 || j==0 || i==(a-1) || j==(b-1)){ + c+=d[i][j]; + } + } + } + cout < +#include +#include +#include +using namespace std; +int main(){ + int a[100][100],max,min,k=0,m=0; + for(int i=0;i<5;i++){ + for(int j=0;j<5;j++){ + cin >>a[i][j]; + } + } + max=a[0][0]; + min=a[0][0]; + for(int i=0;i<5;i++){ + k=0; + m=0; + max=a[i][0]; + for(int j=0;j<5;j++){ + if(a[i][j]>max){ + max=a[i][j]; + k=j; + } + } + min=a[0][k]; + for(int j=0;j<5;j++){ + if(a[j][k] +#include +#include +#include +using namespace std; +int main(){ + int num[10][10]={0};//¼ + int temp;// + int flag[10]={0}; + int ix,iy,ia,ib; + int arr[10][10]={0}; + int sum=0; + cout << "俨Ϸ" << endl; + cout << "16ֿƣ1~8ɣÿֻ2" << endl; + cout << "ϷҪƷ棬ҳͬ" << endl; + cout << "ÿһֻſ" << endl; + cout << "ͬ򽫿ֵһʾ" << endl; + cout << "򽫿Ʒ棬һ" << endl; + cout << "ϵͳϷҳֵͬĿѵIJж֣" << endl; + system("pause"); + srand(time(0)); + for(int j=1;j<=4;j++){ + for(int k=1;k<=4;k++){ + while(true){ + temp=rand()%8+1; + if(flag[temp]<2){ + num[j][k]=temp; + flag[temp]++; + break; + } + else{ + continue; + } + } + } + } + for(int i=1;i<=4;i++){ + for(int j=1;j<=4;j++){ + cout <<"*"<<" "; + } + cout <>ix>>iy; + arr[ix][iy]++; + system("cls"); + for(int i=1;i<=4;i++){ + for(int j=1;j<=4;j++){ + if(arr[i][j]!=0){ + cout <>ia>>ib; + arr[ia][ib]++; + system("cls"); + for(int i=1;i<=4;i++){ + for(int j=1;j<=4;j++){ + if(arr[i][j]!=0){ + cout < +#include +using namespace std; +int main(){ + int a[100][100],b,c; + cin >>b>>c; + for(int i=0;i>a[i][j]; + } + } + for(int i=0;i +#include +using namespace std; +int main(){ + int a; + cin >>a; + for(int i=1;i<=a;i++){ + cout < +using namespace std; +int main(){ + cout <<"* "< +using namespace std; +int main(){ + cout <<"ҹ裬"< +using namespace std; +int main(){ + char a; + cin >>a; + cout <<" "< +using namespace std; +int main(){ + cout <<"Let the time tell the truth."; + return 0; +} diff --git a/输出星期几.cpp b/输出星期几.cpp new file mode 100644 index 0000000..c85be9b --- /dev/null +++ b/输出星期几.cpp @@ -0,0 +1,33 @@ +#include +using namespace std; +int main(){ + int a; + cin >>a; + switch(a){ + case 1: + cout <<"Monday"; + break; + case 2: + cout <<"Tuesday"; + break; + case 3: + cout <<"Wednesday"; + break; + case 4: + cout <<"Thursday"; + break; + case 5: + cout <<"Friday"; + break; + case 6: + cout <<"Saturday"; + break; + case 7: + cout <<"Sunday"; + break; + default: + cout <<"No"; + + } + return 0; +} diff --git a/输出第二个整数.cpp b/输出第二个整数.cpp new file mode 100644 index 0000000..2121938 --- /dev/null +++ b/输出第二个整数.cpp @@ -0,0 +1,12 @@ +#include +using namespace std; +int main(){ + int first; + int second; + int third; + cin >> first; + cin >> second; + cin >> third; + cout < +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +void wjh(int x,int n){ + if(x>n){ + return; + } + cout <>a; + wjh(1,a); + return 0; +} diff --git a/过滤空格.cpp b/过滤空格.cpp new file mode 100644 index 0000000..f420758 --- /dev/null +++ b/过滤空格.cpp @@ -0,0 +1,18 @@ +#include +#include +using namespace std; +int main(){ + string a; + getline(cin,a); + for(int i=0;i +#include +#include +using namespace std; +int main(){ + char a[1000]; + gets(a); + for(int i=0;i +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +using namespace std; +int main(){ + char a[1000]; + cin.getline(a,1000); + for(int i=0;i +#include +#include +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +void wjh(int x){ + cout <<"~"< +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +int main(){ + c a[10000]; + cin >>a; + for(int i=0;i +#include +using namespace std; +int main(){ + float a; + float b; + cin >>a>>b; + cout < +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct rect{ + int c; + int k; + int id; +}arr[10000]; +bool cmp(rect a,rect b){ + if(a.c+a.k==b.c+b.k){ + return a.cb.c+b.k; +} +int main(){ + int a; + cin >>a; + for(int i=0;i>arr[i].c>>arr[i].k; + arr[i].id=i; + } + sort(arr,arr+a,cmp); + for(int i=0;i +#include +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct wjh{ + int x; + int y; +}arr[10000]; +bool cmp(wjh a,wjh b){ + return a.y>a>>b>>c>>d; + for(int i=0;i>arr[i].x>>arr[i].y; + } + sort(arr,arr+a,cmp); + for(int i=0;i +#include +#include +#include +#include +#include +typedef long long l; +typedef double d; +typedef char c; +using namespace std; +struct wjh{ + string name; + char pd; + d tw; +}arr[10000]; +int main(){ + l a; + cin >>a; + for(int i=0;i>arr[i].name>>arr[i].pd>>arr[i].tw; + } + for(int i=0;i +#include +#include +#include +#include +using namespace std; +int main(){ + for(int i=0;i<=40;i++){ + for(int j=0;j<=40;j++){ + for(int k=0;k<=40;k++){ + if(i+j+k==40 && i*8+j*16+k*50==560){ + cout < +using namespace std; +int main(){ + cout <<"->( O_o)?"<( \" _ \")/(T_T)"<( o )"<