⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1007(附带取各位数字的算法).txt

📁 KMP字符串匹配的c实现
💻 TXT
字号:
#include<iostream.h>
#include<math.h>


int main(){
	const int d=9;
	int n;
	int N;
	int pn9;
	int pn10;
	int t;
	int temp;
	int tempN;
	int a;
	while(cin>>n&&n){
		N=100000000;
		pn9=0;
		pn10=0;
		while(n<N){
			N/=10;
		}
		cout<<n<<": ";
		tempN=N;
		
		while(N){ //,5,6,7,8,9->4,5,6,7,8,
			temp=n/N;
			if(temp>4)
				--temp;
			pn9+=temp*N;
			n%=N;
			N/=10;
		}
		t=0; 
		a=pn9; //????pn9????
		while(a){//????????????
			t++;
			a/=10;
		}
	
	   
		while(tempN){    //9????->10????
			pn10=pn10+(pn9/tempN)*(pow(d,--t));
			pn9%=tempN;
			tempN/=10;
		}
		
		cout<<pn10<<endl;
	}
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -