There is a sequence array Seq={a,b,c,d,aa,ba,ca,da,ab,bb,cb,db,ac,bc,cc,dc,ad,...... aaa,baa,caa,daa,aba,bba,cba,dba .....

Source: Internet
Author: User
Tags dba

This is Ali's latest test, and the following code prints the required string. If you have other questions, you can modify the following code to provide additional functionality.

As you can see from the title, the character growth is 4 times times changed. The first time is four, the second is 16, in turn, 64,128, ..... ....... ......... From above, and with certain regularity.

void Seq_string () {char str[1100][10];//apply for a two-bit character array memset (str, ' I ', sizeof (str));  int i=0,j=0,k=0,t=1,m=0,w,q=0,p=0,f;

	T is used to store the length of a series of characters, m stands for rows, and n represents the column char *temp= "ABCD";    for (I=0;i<strlen (temp); i++) {str[m++][k]=temp[i]; First assigns "ABCD" to the Array,} k++;    K is used to denote the number of columns, that is, a line with several characters while (1) {j=0;j<=k;j++) {t*=4;  The characters in turn increase with the power of 4, and T is used to save the number of strings that need to be added next time} w=t;         W is used to temporarily save the value of T f=m; F is used to temporarily save the number of rows at that time, for the (i=0;i<=k;i++) {while (t--)/cycles, the first time is 4, the second is 4*4, and then the multiples of 4 are increased by {if (i==0)///At the first time 
				   Assigned respectively, A,b,c,d {str[m++][i]=temp[q++];
				   if (q==4) {q=0;
					} else {//str[m++][i]=temp[] strcat (Str[m++],str[p]); The number of t/4,p before replication increases by 1 with a string of 4. So, there are the following
					if (t%4==0) {p++;  }} t=w;

		Cycle again, m=f; } m=w+f;
		After a loop, M is F plus the number of additions.   T=1;
		Turn T into 1 and continue to the next cycle if (m>1010) {break;
	} for (i=0;i<100;i++) {printf ("%d:%s\n", I,str[i]); }
				
}


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.