回文数
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
for (ll i=1000; i<=9999; i++){
ll a=i/1000;
ll b=(i/100)%10;
ll c=(i/10)%10;
ll d=i%10;
if (a==d&&b==c)cout<<i<<endl;
}
return 0;
}
特殊的数字
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
for (ll i=100; i<=999; i++){
ll a=i/100;
ll b=(i/10)%10;
ll c=i%10;
if (a*a*a+b*b*b+c*c*c==i)cout<<i<<endl;
}
return 0;
}
数列特征
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
ll n;
cin>>n;
ll a[n];
ll num=0;
for(ll i=0; i<n; i++){
cin>>a[i];
num+=a[i];
}
sort(a,a+n);
cout<<a[n-1]<<endl;
cout<<a[0]<<endl;
cout<<num<<endl;
return 0;
}
字母图形
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
typedef long long ll;
struct A{
int x;
};
int main()
{
ll n;
ll m;
cin>>n>>m;
string s="";
for (ll i=0; i<m; i++){
s+='A'+i;
}
cout<<s<<endl;
for (ll i=1; i<n; i++){
s=char(s[0]+1)+(s.substr(0,m-1));
cout<<s<<endl;
}
return 0;
}
01字串
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
typedef long long ll;
int main()
{
for(ll i=0; i<=1; i++)
for(ll j=0; j<=1; j++)
for(ll k=0; k<=1; k++)
for(ll m=0; m<=1; m++)
for(ll n=0; n<=1; n++){
string s="";
s=s+char(i+'0')+char(j+'0')+char(k+'0')+char(m+'0')+char(n+'0');
cout<<s<<endl;
}
return 0;
}