没事练练手,顺便说下大小写字母共52个,楼主说有33个字符我怎么数都只有32个,后来加了个=号凑足33个,总共95个字符
按进位的方法做的。
仔细思考了一下应该不止95^3,因为还包括只输入1位数和2位数的情形,总和应为95^3+95^2+95=866495
修改如下:
#include <stdio.h>
#define N 3
char a[]={' ','0','1','2','3','4','5','6','7','8','9','a',
'b','c','d','e','f','g','h','i','j','k',
'l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','A','B','C','D','E','F','G',
'H','I','J','K','L','M','N','O','P','Q','R',
'S','T','U','V','W','X','Y','Z','[',']','~',
'.','\'',',','/','\\',':','!','?','@','#','$',
'%','^','&','*','(',')','<','>','_','+','|',
'~','`','{','}','-','=',';','"'};
int count=0;
void print(int *m,FILE *fp)
{
int i;
for(i=0;m[i]==0;i++);
while(i<=N)
{
fprintf(fp,"%c",a[m[i]]);
i++;
}
fprintf(fp," ");
}
void cy(char *a,int n,FILE *fp)
{
int k,l,m[N+1]={0};
if(fp==NULL)return;
for(int i=1,j=n;j>0;)
{
k=n;
m[k]=1;
while(a[i]!='\0')
{
print(m,fp);
m[k]++;
i++;
count++;
}
i=1;
while(m[k]==96)
{
m[k]=1;
k--;
m[k]++;
}
for(l=0;m[l]==0;l++);
j=l;
}
}
main()
{
FILE *fp;
fp=fopen("c:\\a.txt","w");
if(fp==NULL)return 0;
cy(a,N,fp);
printf("%d",count);
}
[此贴子已经被作者于2017-7-8 11:44编辑过]