Files
python/C++专题课程/NOIP算法总结/模拟/JAM计数法/P1061.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

40 lines
939 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <iostream>
using namespace std;
int main()
{
char ch[26],l,r;
int w,i,k,j;
cin>>i>>j>>w;
l=i+'a'-1; //把数字转换成字母
r=j+'a'-1;
cin>>ch;
for(i=1;i<=5;i++)
{
j=w-1; //从'个位'开始加
cout<<"从'个位'开始加 i的数值:"<<i<<endl;
//------------------------------------------------重
while(j>=0&&ch[j]==r+j+1-w)
{
printf("%c ",r+j+1-w);
cout<<ch[j]<<" "<<"ttt这个时候的j:"<<j<<" 这个时候的ch:"<<ch<<endl;
j--; //找到当前为了把数变大,所必须进的位最小在哪
}
if(j==-1)
break;
//------------------------------------------------点
cout<<"yuanlai:"<<ch[j];
ch[j]++; //进位
cout<<"升级进位变成:"<<ch[j]<<endl;
for (k=j+1;k<=w-1;k++)
ch[k]=ch[k-1]+1; //所需进位之后的所有位都需变大
cout<<ch<<endl;
}
return 0;
}
/*
备注:数字中,是1<2<3<4...
而Jam数中,则是a>b>c>d...
*/