编程基础
1.妮妮的反转游戏
#include<iostream>
using namespace std;
int main(){
int x;
cin>>x;
if(x==0)cout<<1<<"\n";
if(x==1)cout<<0<<"\n";
return 0;
}
输入向右
常用库函数
STL
2.顺子日期,不建议看
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int month[]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int main(){
int ans=0;
for(int i=0;i<2;i++)
for(int j=0;j<10;j++){
int k=j+1;
for(int l=0;l<10;l++){
int m=i*10+j;
int d=k*10+l;
if(m<13&&d<=month[m]&&(i==j-1||k==l-1))
cout<<m<<" "<<d<<endl;
ans++;
}
}
cout<<ans<<endl;
return 0;
}
这题纯****,别试了
3.小明和完美序列 OJ:3199
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
signed main()
{
int n; cin >> n;
vector<int> a(n + 1);
map<int, int> cnt;
for(int i = 1; i <= n; i ++) {
cin >> a[i];
cnt[a[i]] ++;
}
int ans = 0;
for(auto [x, y] : cnt) {
if(y > x) ans += y - x;
else if(y < x) ans += y;
}
cout << ans;
}