2018软件-B-C(空)-好数字-发财树-

A二进制反转

每组数据输入一个十进制数x(0<x<2^32),将其二进制位反转(共32位),然后输出对应的十进制数

输入样例#:
2
2
3
输出样例#:
1073741824
3221225472
提示
2^32-1超出了int的范围,请使用long long

数字横向

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	int a0[5][3]={{1,1,1},{1,0,1},{1,0,1},{1,0,1},{1,1,1}};
	int a1[5][3]={{0,0,1},{0,0,1},{0,0,1},{0,0,1},{0,0,1}};
	int a2[5][3]={{1,1,1},{0,0,1},{1,1,1},{1,0,0},{1,1,1}};
	int a3[5][3]={{1,1,1},{0,0,1},{1,1,1},{0,0,1},{1,1,1}};
	int a4[5][3]={{1,0,1},{1,0,1},{1,1,1},{0,0,1},{0,0,1}};
	int a5[5][3]={{1,1,1},{1,0,0},{1,1,1},{0,0,1},{1,1,1}};
	int a6[5][3]={{1,1,1},{1,0,0},{1,1,1},{1,0,1},{1,1,1}};
	int a7[5][3]={{1,1,1},{0,0,1},{0,0,1},{0,0,1},{0,0,1}};
	int a8[5][3]={{1,1,1},{1,0,1},{1,1,1},{1,0,1},{1,1,1}};
	int a9[5][3]={{1,1,1},{1,0,1},{1,1,1},{0,0,1},{1,1,1}};
	char h[10000];
	cin>>h;
	int length=0;
	int h2[10000];
	for(int i=0;;i++){
		if(h[i]!='\0'){
			h2[length]=h[i]-'0';
			length++;
		}	
		else
			break;
	}
	for(int i=0;i<5;i++){
		for(int j=0;j<length;j++){
			if(h2[j]==0){
				for(int k1=0;k1<3;k1++)
					cout<<a0[i][k1];
			}
			if(h2[j]==1){
				for(int k1=0;k1<3;k1++)
					cout<<a1[i][k1];
			}
			if(h2[j]==2){
				for(int k1=0;k1<3;k1++)
					cout<<a2[i][k1];
			}
			if(h2[j]==3){
				for(int k1=0;k1<3;k1++)
					cout<<a3[i][k1];
			}
			if(h2[j]==4){
				for(int k1=0;k1<3;k1++)
					cout<<a4[i][k1];
			}
			if(h2[j]==5){
				for(int k1=0;k1<3;k1++)
					cout<<a5[i][k1];
			}
			if(h2[j]==6){
				for(int k1=0;k1<3;k1++)
					cout<<a6[i][k1];
			}
			if(h2[j]==7){
				for(int k1=0;k1<3;k1++)
					cout<<a7[i][k1];
			}
			if(h2[j]==8){
				for(int k1=0;k1<3;k1++)
					cout<<a8[i][k1];
			}
			if(h2[j]==9){
				for(int k1=0;k1<3;k1++)
					cout<<a9[i][k1];
			}
		}
		cout<<endl;
	}
	return 0; 
}

#include<iostream>
#include<string.h>
using namespace std;
int main(){
	string row1[]={"001","002","003","004"};
	string row2[]={"001","002","003","004"};
	string row3[]={"001","002","003","004"};
	string row4[]={"001","002","003","004"};
	string row5[]={"001","002","003","004"};
	string gou;
	while(cin>>gou){
		int s=0;
		while(s<gou.length()){
			int cur=gou[s]-'0';
			cout<<row1[cur];
            s++;
		}
		cout<<endl;
		s=0;
			while(s<gou.length()){
			int cur=gou[s]-'0';
			cout<<row2[cur];s++;
		}
		s=0;
		cout<<endl;
			while(s<gou.length()){
			int cur=gou[s]-'0';
			cout<<row3[cur];s++;
		}
		s=0;
		cout<<endl;
			while(s<gou.length()){
			int cur=gou[s]-'0';
			cout<<row4[cur];s++;
		}
		s=0;
		cout<<endl;
			while(s<gou.length()){
			int cur=gou[s]-'0';
			cout<<row5[cur];s++;
		}
		cout<<endl;
	}
}

3.发财数

题目描述:一个数字如果是由8个及8个以上的质因数乘积而成的数为发财数

输入:数字n

输出:10000以内的第几个发财数

举例:输入:1  输出:256

4 18-c  v型

#include<iostream>
using namespace std;

int main(){
	int n;cin>>n;
	int num[100];
	for(int i=0;i<n;i++){
		cin>>num[i];
	}
	int count=0;
	for(int i=0;i<n;i++){
		for(int j=i;j<n;j++){
			for(int k=j;k<n;k++){
				if(num[i]>num[j]&&num[i]>num[k]) count++;
			}
		}
	
}
cout<<count<<endl;
}

5

//好数字 包含2018四个数字 
 #include<iostream>
 #include<string>//find 查不到返回-1 
 #include<string.h>
using namespace std;

bool check(int n){
	string temp =to_string(n);
	if(temp.find('2')!=-1&&temp.find('0')!=-1&&temp.find('1')!=-1&&temp.find('8')!=-1) return true; 
    return false;
}


int main(){
	int n;
	while(cin>>n){
	int count=0;
	for(int i=0;i<n;i++){
		if(check(i)==true)	 count++;
	}
	cout<<count<<endl;
	}
		return 0;	
}
//好数字 包含2018四个数字 
 #include<iostream>
 #include<string>//find 查不到返回-1 
 #include<string.h>
using namespace std;

bool check(int n){
	string temp =to_string(n);
	if(temp.find('2')!=-1&&temp.find('0')!=-1&&temp.find('1')!=-1&&temp.find('8')!=-1) return true; 
    return false;
}

int result[1000000];
int main(){
	int n;
	memset(result,0,sizeof(result));
	
	for(int i=0;i<1000000;i++){
		if(check(i)==true)	 result[i]=result[i-1]+1;
	    else	result[i]=result[i-1];
	}
	while(cin>>n){
	
	cout<<result[n]<<endl;
	}
		return 0;	
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值