更新了许多

This commit is contained in:
OhFengGO 2023-08-23 21:52:51 +08:00
parent 971a1d91d6
commit fc324f936b
197 changed files with 6500 additions and 0 deletions

26
三整数排序(2).cpp Normal file
View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
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 <<a<<" "<<b<<" "<<c;
return 0;
}

37
三整数排序.cpp Normal file
View File

@ -0,0 +1,37 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a,b,c;
cin >>a>>b>>c;
if(a<=b && a<=c){
cout <<a<<" ";
}
else if(b<=a && b<=c){
cout <<b<<" ";
}
else if(c<=a && c<=b){
cout <<c<<" ";
}
if((a>=c && a<=b) || (a<=c && a>=b)){
cout <<a<<" ";
}
else if((b>=c && b<=a) || (b<=c && b>=a)){
cout <<b<<" ";
}
else if((c>=a && a<=b) || (c<=a && c>=b)){
cout <<c<<" ";
}
if(a>=b && a>=c){
cout <<a;
}
else if(b>=a && b>=c){
cout <<b;
}
else if(c>=b && c>=a){
cout <<c;
}
return 0;
}

27
三角形判断.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int a;
int b;
int c;
cin >>a>>b>>c;
if(a<b+c && b<a+c && c<b+a){
if(a==b && a==c && b==c){
cout <<"等边三角形";
}
else if(a==b || a==c || b==c){
cout <<"等腰三角形";
}
else if(pow(a,2)+pow(b,2)==pow(c,2)){
cout <<"直角三角形";
}
else{
cout <<"一般三角形";
}
}
else{
cout <<"不是三角形";
}
return 0;
}

15
三角形组成判断.cpp Normal file
View File

@ -0,0 +1,15 @@
#include <iostream>
using namespace std;
int main(){
int a;
int b;
int c;
cin >>a>>b>>c;
if(a<b+c && b<a+c && c<b+a){
cout <<"yes";
}
else{
cout <<"no";
}
return 0;
}

View File

@ -0,0 +1,19 @@
#include <iostream>
using namespace std;
int main(){
int n,m,b=0;
int a[10000];
cin >>n;
for(int i=0;i<n;i++){
cin >>a[i];
}
cin >>m;
for(int i=0;i<n;i++){
if(a[i]==m){
b++;
}
}
cout <<b;
return 0;
}

View File

@ -0,0 +1,18 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a,b[1000],c,sum=0;
cin >>a;
for(int i=0;i<a;i++){
cin >>b[i];
}
cin >>c;
for(int i=0;i<a;i++){
if(b[i]==c){
sum++;
}
}
cout <<sum;
return 0;
}

26
世界末日.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
void wjh(int x,int n){
if(n<x-1){
return;
}
cout <<n<<" ";
wjh(x,n-1);
}
int main(){
int a;
cin >>a;
wjh(1,a);
return 0;
}

8
两位数反转.cpp Normal file
View File

@ -0,0 +1,8 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >> a;
cout <<a%10<<a/10;
return 0;
}

26
买书.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
using namespace std;
int main(){
int a,b[10000],c,d[10000];
cin >>a;
int sum=0;
for(int i=0;i<a;i++){
cin >>b[i];
}
cin >>c;
for(int i=0;i<c;i++){
cin >>d[i];
}
for(int i=0;i<c;i++){
for(int j=0;j<d[i];j++){
sum+=b[j];
}
cout <<sum<<" ";
sum=0;
}
return 0;
}

13
买木板.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b;
scanf("%d%d",&a,&b);
printf("一共%d元。找零%d元",a*20,b-a*20);
return 0;
}

18
二维数字排列.cpp Normal file
View File

@ -0,0 +1,18 @@
#include <iostream>
#include <iomanip>
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 <<a<<" ";
}
cout <<endl;
}
return 0;
}

13
人口增长问题.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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

16
优美数.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <bits/stdc++.h>
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;
}

20
位运算符.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
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="<<c<<endl;
cout <<"a|b="<<d<<endl;
cout <<"a^b="<<e<<endl;
cout <<"~a="<<f<<endl;
cout <<"a<<b="<<(a<<b)<<endl;
cout <<"a>>b="<<(a>>b)<<endl;
return 0;
}

34
你的飞碟在这儿.cpp Normal file
View File

@ -0,0 +1,34 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<strlen(a);i++){
a1[i]=a[i]-64;
}
for(int i=0;i<strlen(b);i++){
b1[i]=b[i]-64;
}
for(int i=0;i<strlen(a);i++){
sum1*=a1[i];
}
for(int i=0;i<strlen(b);i++){
sum2*=b1[i];
}
if(sum1%47==sum2%47){
cout <<"GO";
}
else{
cout <<"STAY";
}
return 0;
}

22
分段函数.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
double a;
cin >>a;
if(0<=a && a<5){
cout <<fixed<<setprecision(3)<<(0-a)+2.5;
}
if(5<=a && a<10){
cout <<fixed<<setprecision(3)<<2-1.5*(a-3.0)*(a-3.0);
}
if(10<=a && a<20){
cout <<fixed<<setprecision(3)<<a/2.0-1.5;
}
return 0;
}

View File

@ -0,0 +1,16 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
long long a;
scanf("%lld",&a);
while(a){
printf("%lld ",a%10);
a/=10;
}
return 0;
}

13
判断数字的奇偶.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >> a;
if(a%2==0){
cout <<"even";
}
else{
cout <<"odd";
}
return 0;
}

16
判断数字的正负.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <bits/stdc++.h>
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;
}

20
判断数正负.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
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;
}

18
判断正整数位数.cpp Normal file
View File

@ -0,0 +1,18 @@
#include <iostream>
using namespace std;
int main(){
int a,b=0;
cin >>a;
if(a==0){
cout <<"1";
return 0;
}
while(a){
a/=10;
b++;
}
cout <<b;
return 0;
}

14
判断素数.cpp Normal file
View File

@ -0,0 +1,14 @@
#include <iostream>
using namespace std;
int main(){
int a,b=0;
cin >>a;
for(int i=2;i*i<=a;i++){
if(a%i==0){
cout <<a<<" is a prime number.";
return 0;
}
}
cout <<a<<" is not a prime number.";
return 0;
}

13
判断闰年.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <bits/stdc++.h>
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;
}

View File

@ -0,0 +1,26 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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%2;
}
int main(){
int a;
cin >>a;
wjh(a);
return 0;
}

9
叠罗汉.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <iostream>
using namespace std;
int main(){
cout <<" # "<<endl;
cout <<" # # "<<endl;
cout <<" # # # "<<endl;
cout <<"# # # #"<<endl;
return 0;
}

11
叠罗汉升级版.cpp Normal file
View File

@ -0,0 +1,11 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
char a;
cin >>a;
cout <<" "<<a<<" "<<endl;
cout <<" "<<a<<" "<<a<<" "<<endl;
cout <<" "<<a<<" "<<a<<" "<<a<<" "<<endl;
cout <<a<<" "<<a<<" "<<a<<" "<<a;
return 0;
}

25
含K个3的数.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
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;
}

26
哥德巴赫猜想.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <iostream>
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<i;j++){
if(i%j==0){
flag1=0;
break;
}
}
for(int k=2;k<a-i;k++){
if((a-i)%k==0){
flag2=0;
break;
}
}
if(flag1==1 && flag2==1){
cout <<a<<"="<<i<<"+"<<a-i;
break;
}
}
return 0;
}

35
图像模糊化处理.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<a;i++){
for(int j=0;j<b;j++){
cin >>c[i][j];
}
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
e[i][j]=c[i][j];
}
}
for(int i=1;i<a-1;i++){
for(int j=1;j<b-1;j++){
c[i][j]=round((e[i+1][j]+e[i-1][j]+e[i][j-1]+e[i][j+1]+e[i][j])*1.0/5);
}
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
cout <<c[i][j]<<" ";
}
cout <<endl;
}
return 0;
}

16
圆柱体的表面积.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
const double pi = acos(-1.0);
double r;
double h;
cin >>r>>h;
cout <<"Area = "<<fixed<<setprecision(3)<<2*pi*r*h+2*pi*pow(r,2);
return 0;
}

16
奇数求和.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <bits/stdc++.h>
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 <<c;
return 0;
}

16
好吃or不好吃.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <iostream>
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;
}

View File

@ -0,0 +1,17 @@
#include <iostream>
#include <cstring>
using namespace std;
int main(){
char a[10000];
cin >>a;
for(int i=0;i<strlen(a);i++){
if(a[i]>='0' && a[i]<='9'){
}
else{
cout <<a[i];
}
}
return 0;
}

24
字符倒三角.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <iostream>
#include <iomanip>
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 <<b<<" ";
b++;
if(b>'z'){
b-=26;
}
}
cout <<endl;
}
return 0;
}

22
密码破解.cpp Normal file
View File

@ -0,0 +1,22 @@
#include <iostream>
#include <cstring>
using namespace std;
int main(){
char a[10000];
int b=0,sum=0;
cin >>a;
for(int i=0;i<strlen(a);i++){
if(a[i]>='0' && a[i]<='9'){
b=b*10+(a[i]-48);
}
else{
sum+=b;
b=0;
}
}
sum+=b;
cout <<sum;
return 0;
}

27
密码翻译.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<strlen(a);i++){
if((a[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 <<a;
return 0;
}

View File

@ -0,0 +1,17 @@
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
int main(){
long long money=1;
long long sum=1;
int day=1;
for(day=1;day<=1234567890;day+=1){
cout <<"当前是约定的第"<<day<<""<<endl;
cout <<"国王当天给富豪的钱数是:"<<money<<endl;
cout <<"国王累计给富豪的钱数是:"<<sum<<endl;
money=money*2;
sum=sum+money;
}
return 0;
}

13
对齐输出.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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;
}

View File

@ -0,0 +1,25 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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 <<wjh(a)*2;
return 0;
}

View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
double a;
double b;
long long c;
cin >>a>>b>>c;
cout <<c<<endl;
cout <<fixed<<setprecision(2)<<b<<endl;
cout <<fixed<<setprecision(9)<<a;
return 0;
}

13
小玉在游泳.cpp Normal file
View File

@ -0,0 +1,13 @@
#include <iostream>
using namespace std;
int main(){
double a,b=2.0,sum=0,c=0;
scanf("%lf",&a);
while(sum<a){
sum+=b;
b*=0.98;
c++;
}
printf("%.0lf",c);
return 0;
}

19
小玉家的电费.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >>a;
if(a<=150){
cout <<fixed<<setprecision(1)<<a*0.4463;
return 0;
}
if(a>150 && a<=400){
cout <<fixed<<setprecision(1)<<150*0.4463+(a-150)*0.4663;
return 0;
}
if(a>400){
cout <<fixed<<setprecision(1)<<150*0.4463+(400-150)*0.4663+(a-400)*0.5663;
return 0;
}
return 0;
}

19
小码君分班.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b;
cin >>a>>b;
if(b%a==0){
cout <<"每班"<<b/a<<"个学生。"<<endl;
}
else{
cout <<"每班"<<b/a<<"个学生。"<<endl;
cout <<"还有"<<b-b/a*a<<"个学生没分班。";
}
return 0;
}

39
小码君分配宿舍.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<b.id;
}
return a.n<b.n;
}
return a.m<b.m;
}
int main(){
int a;
cin >>a;
for(int i=0;i<a;i++){
cin >>arr[i].name>>arr[i].n>>arr[i].m;
arr[i].id=i;
}
sort(arr,arr+a,cmp);
for(int i=0;i<a;i++){
cout <<arr[i].name<<" "<<arr[i].n<<" "<<arr[i].m<<endl;
}
return 0;
}

25
小码君刷题.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b,c,d,e,sum=0;
cin >>a>>b>>c>>d>>e;
for(int i=0;i<a;i++){
if(i>=1 && i%c==0){
b+=d;
}
sum+=b;
}
cout <<sum<<endl;
if(sum>=e){
cout <<"Yes";
}
else{
cout <<"No";
}
return 0;
}

View File

@ -0,0 +1,25 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<a;i++){
for(int j=0;j<b;j++){
cin >>c[i][j];
}
}
for(int i=b-1;i>=0;i--){
for(int j=0;j<a;j++){
cout <<c[j][i]<<" ";
}
cout <<endl;
}
return 0;
}

33
小码君打地鼠.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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 <<arr[1][1];
return 0;
}

29
小码君打比赛.cpp Normal file
View File

@ -0,0 +1,29 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<a;i++){
cin >>c[i];
}
for(int i=0;i<a;i++){
cin >>d[i];
}
for(int i=0;i<a;i++){
if(d[i]==1){
b[i]=floor(b[i]*1.0/2);
}
}
for(int i=0;i<a;i++){
}
return 0;
}

38
小码君查房-2.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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 <<i<<" ";
flag=1;
}
}
if(flag==0){
cout <<0;
}
return 0;
}

34
小码君查房.cpp Normal file
View File

@ -0,0 +1,34 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<a;i++){
if(c[i]>=40 && i==d[i]){
flag1=1;
flag2=1;
cout <<i<<" ";
}
if(c[i]>=40 && i!=d[i]){
flag2=1;
}
}
if(flag1==0 && flag2!=0){
cout <<"luck";
}
if(flag2==0){
cout <<"quiet";
}
return 0;
}

View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
char a[10000];
int sum=0;
gets(a);
for(int i=0;i<strlen(a);i++){
if(a[i]=='A' && a[i+1]=='A' && a[i+2]=='C'){
sum+=2;
}
else if(a[i]=='A' && a[i+1]=='C' && a[i+2]=='C'){
sum+=2;
}
else if(a[i]=='A' && a[i+1]=='C' && (a[i]!='C' && a[i]!='A')){
sum++;
}
}
cout <<sum;
return 0;
}

View File

@ -0,0 +1,28 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<strlen(a);i++){
if(a[i]=='D'){
tem=1;
}
if(a[i]==','){
cnt+=tem;
tem=0;
}
}
cnt+=tem;
cout <<cnt;
return 0;
}

32
小码君的F91函数.cpp Normal file
View File

@ -0,0 +1,32 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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("<<a<<") = "<<f91(a)<<endl;
}
return 0;
}

View File

@ -0,0 +1,35 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<strlen(a);i++){
if(i==1 || i==5 || i==11){
continue;
}
b[i]=a[i]-48;
}
for(int i=0;i<strlen(a);i++){
if(i==1 || i==5 || i==11){
continue;
}
sum+=c*b[i];
c++;
}
if(sum%11==10){
cout <<"X";
}
else{
cout <<sum%11;
}
return 0;
}

View File

@ -0,0 +1,63 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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<node> 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;
}

View File

@ -0,0 +1,64 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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<node> que;
que.push({sx,sy,1});
while(!que.empty()){
node first=que.front();
que.pop();
if(first.x==ex && first.y==ey){
cout <<first.dp;
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]!='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;
}

View File

@ -0,0 +1,57 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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<node> que;
que.push({sx,sy,0});
while(!que.empty()){
node first=que.front();
que.pop();
if(first.x==ex && first.y==ey){
cout <<first.dp;
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<=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;
}

View File

@ -0,0 +1,47 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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 <<ans;
return 0;
}

View File

@ -0,0 +1,38 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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"<<" "<<b-c;
}
if(b==c){
cout <<"draw";
}
if(b<c){
cout <<"luo"<<" "<<c-b;
}
return 0;
}

View File

@ -0,0 +1,46 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
typedef long long l;
typedef double d;
typedef char c;
using namespace std;
stack<int> 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 <<stk.size()<<" "<<stk.top()+1;
}
return 0;
}

View File

@ -0,0 +1,31 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<a;i++){
for(int j=0;j<b;j++){
cin >>c[i][j];
}
}
cin >>h>>l>>g;
cin >>lie>>hang>>s;
for(int i=l-1;i<l+g-1;i++){
cout <<c[h-1][i]<<" ";
sum+=c[h-1][i];
}
cout <<endl;
for(int i=hang-1;i<hang+s-1;i++){
cout <<c[i][lie-1]<<" ";
sum+=c[i][lie-1];
}
cout <<endl<<sum;
return 0;
}

33
小码君的同学录.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<a;i++){
cin >>arr[i].name>>arr[i].age>>arr[i].sg>>arr[i].tz>>arr[i].xb;
}
for(int i=0;i<a;i++){
if(arr[i].xb=='M'){
printf("His name is %s, he is %lld years old, he is %.1lf meters tall and weighs %.1lf kg.\n",arr[i].name,arr[i].age,arr[i].sg,arr[i].tz);
}
if(arr[i].xb=='F'){
printf("Her name is %s, she is %lld years old, she is %.1lf meters tall and weighs %.1lf kg.\n",arr[i].name,arr[i].age,arr[i].sg,arr[i].tz);
}
}
return 0;
}

View File

@ -0,0 +1,56 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<b;j++){
cout <<"-";
}
}
if(i%2==0){
for(int j=0;j<c;j++){
cout <<"|";
}
}
cout <<endl;
}
else{
if(i%2==1){
for(int j=0;j<b;j++){
cout <<"-";
}
}
if(i%2==0){
for(int j=0;j<(b-c)/2;j++){
cout <<" ";
}
for(int j=0;j<c;j++){
cout <<"|";
}
}
cout <<endl;
}
}
return 0;
}

40
小码君的好同学.cpp Normal file
View File

@ -0,0 +1,40 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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<int> 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 <<que.front()<<" ";
que.pop();
}
return 0;
}

View File

@ -0,0 +1,41 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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;j<i;j++){
if(arr[i]>arr[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 <<max1;
return 0;
}

View File

@ -0,0 +1,31 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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 <<res;
return 0;
}

20
小码君的小卖部.cpp Normal file
View File

@ -0,0 +1,20 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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;
}

41
小码君的山.cpp Normal file
View File

@ -0,0 +1,41 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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 <<cnt<<endl;
for(int i=1;i<=cnt;i++){
for(int j=1;j<=2;j++){
cout <<r[i][j]<<" ";
}
cout <<endl;
}
return 0;
}

View File

@ -0,0 +1,30 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<strlen(a);i++){
if((a[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;
}

View File

@ -0,0 +1,20 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
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 <<i<<" "<<j<<" "<<k<<endl;
}
}
}
}
return 0;
}

View File

@ -0,0 +1,25 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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 <<i<<" "<<j<<" "<<k<<" "<<d<<" "<<g<<endl;
}
}
}
}
}
}
return 0;
}

View File

@ -0,0 +1,24 @@
#include <iostream>
#include <iomanip>
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<b*2-1;k++){
cout <<c;
c++;
if(c>=10){
c=0;
}
}
cout <<endl;
b++;
}
return 0;
}

View File

@ -0,0 +1,38 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
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<strlen(a);i++){
if(a[i]=='('){
cnt1++;
}
if(a[i]==')'){
cnt1--;
}
if(cnt1<0){
cout<<"NO"<<endl;
return 0;
}
}
if(cnt1==0){
cout<<"YES"<<endl;
return 0;
}
else{
cout<<"NO"<<endl;
return 0;
}
return 0;
}

View File

@ -0,0 +1,33 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <algorithm>
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<a;i++){
cin >>arr[i].name>>arr[i].age>>arr[i].y;
}
for(int i=0;i<a;i++){
if(floor(arr[i].age*1.0*5+arr[i].y*1.0/2)>max1){
max1=floor(arr[i].age*1.0*5+arr[i].y*1.0/2);
b=i;
}
}
cout <<b+1<<" "<<arr[b].name;
return 0;
}

21
小码君的概率学.cpp Normal file
View File

@ -0,0 +1,21 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;
int main(){
int a,b;
cin >>a>>b;
if(a>b){
cout <<"nO";
}
else if(a<b){
cout <<"yEs";
}
else if(a==b){
cout <<"equal probability";
}
return 0;
}

View File

@ -0,0 +1,25 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a[1000];
int b;
cin >>b;
for(int i=0;i<b;i++){
cin >>a[i];
}
for(int i=0;i<b;i++){
if(a[i]<=10){
cout <<i+1<<" ";
}
}
cout <<endl;
for(int i=0;i<b;i++){
if(a[i]>10){
cout <<i+1<<" ";
}
}
return 0;
}

View File

@ -0,0 +1,34 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<a;i++){
for(int j=0;j<b;j++){
c[i][j]=1;
}
}
for(int i=0;i<a;i++){
c[i][e-1]=0;
}
for(int i=0;i<b;i++){
c[d-1][i]=0;
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
if(c[i][j]==0){
cout <<i+1<<" "<<j+1;
cout <<endl;
}
}
}
return 0;
}

27
小码君的烦恼.cpp Normal file
View File

@ -0,0 +1,27 @@
#include <iostream>
#include <iomanip>
#include <cstring>
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<strlen(a);i++){
if((a[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;
}

View File

@ -0,0 +1,52 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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<point> 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 <<res;
return 0;
}

View File

@ -0,0 +1,30 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
int a[100][100],b,c,d=0;
cin >>b>>c;
for(int i=0;i<b;i++){
for(int j=0;j<c;j++){
cin >>a[i][j];
}
}
for(int i=0;i<b;i++){
for(int j=b-1;j>=0;j--){
if(a[i][j]!=0){
cout <<i+1<<" "<<j+1<<" "<<a[i][j];
d++;
cout <<endl;
}
}
if(d==0){
cout <<"empty"<<endl;
}
d=0;
}
return 0;
}

View File

@ -0,0 +1,13 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
char a[1000],c;
int b;
cin >>a>>b>>c;
a[b]=c;
cout <<a;
return 0;
}

View File

@ -0,0 +1,58 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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<int> 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 <<cnt;
return 0;
}

View File

@ -0,0 +1,30 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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 <<f(e);
return 0;
}

View File

@ -0,0 +1,34 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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 <<x;
}
else{
x=a%b+48;
cout <<x;
}
}
int main(){
int a,b;
cin >>a>>b;
wjh(a,b);
return 0;
}

View File

@ -0,0 +1,26 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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 <<fixed<<setprecision(3)<<s(a,b*10,c)*1.0/(s(a,b*2,c*1.0/2)*s(a*1.0/2,b-a,c*2));
return 0;
}

35
小码君统计数1.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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 <<d[j]<<" "<<max1;
}
}
}
return 0;
}

View File

@ -0,0 +1,21 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<a;j++){
cin >>b[i][j];
}
}
for(int i=0;i<a;i++){
sum+=b[0][i]*b[1][i];
}
cout <<sum;
return 0;
}

30
小码君闯迷宫.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <stack>
#include <ctime>
#include <cmath>
#include <queue>
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 <<a[1][1];
return 0;
}

View File

@ -0,0 +1,38 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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.id<b.id;
}
return a.sc>b.sc;
}
return a.sc*a.nd>b.sc*b.nd;
}
int main(){
int a;
cin >>a;
for(int i=0;i<a;i++){
cin >>arr[i].sc>>arr[i].nd;
arr[i].id=i;
}
sort(arr,arr+a,cmp);
for(int i=0;i<a;i++){
cout <<arr[i].id+1<<" ";
}
return 0;
}

View File

@ -0,0 +1,36 @@
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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.id<b.id;
}
return a.cg1+floor(a.cg2*1.0/10)>b.cg1+floor(b.cg2*1.0/10);
}
int main(){
int a;
cin >>a;
for(int i=0;i<a;i++){
cin >>arr[i].name>>arr[i].cg1>>arr[i].cg2;
arr[i].id=i;
}
sort(arr,arr+a,cmp);
for(int i=0;i<a;i++){
cout <<arr[i].name<<endl;
}
return 0;
}

23
小鱼比可爱2.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int a,b[1000],c[1000]={0,0,0};
cin >>a;
for(int i=0;i<a;i++){
cin >>b[i];
}
for(int i=0;i<a;i++){
for(int j=i;j<a;j++){
if(b[i]>b[j]){
c[i]++;
}
}
}
for(int i=0;i<a;i++){
cout <<c[i]<<" ";
}
return 0;
}

23
小鱼的航程.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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 <<sum;
return 0;
}

33
年龄与疾病.cpp Normal file
View File

@ -0,0 +1,33 @@
#include <iostream>
#include <cstring>
#include <cstdio>
#include <iomanip>
using namespace std;
int main(){
double a[10000],b,c=0,d=0,e=0,f=0;
cin >>b;
for(int i=0;i<b;i++){
cin >>a[i];
}
for(int i=0;i<b;i++){
if(a[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 <<fixed<<setprecision(2)<<c/b*100<<"%"<<endl;
cout <<fixed<<setprecision(2)<<d/b*100<<"%"<<endl;
cout <<fixed<<setprecision(2)<<e/b*100<<"%"<<endl;
cout <<fixed<<setprecision(2)<<f/b*100<<"%";
return 0;
}

View File

@ -0,0 +1,35 @@
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int n,first=1,cnt=0;
cin >>n;
if(n==1){
cout <<"1=1";
return 0;
}
cout <<n<<"=";
for(int i=2;i<=n;i++){
while(n%i==0){
cnt++;
n/=i;
}
if(cnt>0){
if(first!=1){
cout <<"*";
}
else{
first=0;
}
cout <<i;
if(cnt>=2){
cout <<"^"<<cnt;
}
cnt=0;
}
}
return 0;
}

26
恺撒加密术.cpp Normal file
View File

@ -0,0 +1,26 @@
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <cmath>
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<strlen(a);i++){
if((a[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 <<a;
return 0;
}

25
成年人判断3.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <bits/stdc++.h>
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;
}

19
成绩判定.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <bits/stdc++.h>
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;
}

View File

@ -0,0 +1,12 @@
#include <iostream>
using namespace std;
int main(){
int a;
cin >>a;
while(a<=13){
cout <<a;
cout <<" ";
a+=1;
}
return 0;
}

View File

@ -0,0 +1,13 @@
#include <iostream>
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 <<i<<" ";
}
}
return 0;
}

View File

@ -0,0 +1,15 @@
#include <iostream>
using namespace std;
int main(){
int a,i;
cin >>a;
for(i=1;i<=a;i+=2){
cout <<i<<" ";
}
cout <<endl;
for(i=a;i>=1;i-=3){
cout <<i<<" ";
}
return 0;
}

Some files were not shown because too many files have changed in this diff Show More