, ZJW designed a program, the program's mission is to convert a string of phonetic alphabet to 6 digits (password),
ZJW can use any easy to remember the pinyin string (such as name, Zhong Jia Wei, just write: zhongjiawei) as input, the output 6 digits,
Program transformation process is as follows: the first step: put the pinyin string of a group of six fold, such as zhongjiawei into: zhongj iawei
The second step: put all the characters of vertical in the same location ascll code value addition, 6 Numbers, as the following example, concluded:
227 201 230 211 208 106
Step 3: for each digital processing, that is, each bit of the Numbers together, it is concluded that if it is not a single digit, so continue processing, until become a, for example: 227=& gt; 2 + 2 + 7=11=& gt; 1 + 1=2
After the above steps, the password is: 235417, this is the bank card password ZJW last
Input format:
The first line of input a T (0 & lt; T <100), said the number of sets of test data, a line, each group of data on behalf of a given pinyin string, length of not more than 20 to ensure are all lowercase English
The output format:
ZJW last bank card password, a set of data a line
Input the sample:
Given a set of input here, for example:
2
Zhongjiawei
Haohaoxuexi
The output sample:
Here is given the corresponding output, for example:
235417
875843
CodePudding user response:
Did you write this as a freshman? Difficulty is unlikely, but write a headacheconst int MAX=100;
Const int LENTH=20;
Char num [4] [6]={0};
Int j [6]={0};
Int m_deal [6]={0};
Int asccii ()
{
For (int j=0; J & lt; 6; J++)
{
Int mo=0;
For (int k=0; K & lt; 4. K++)
{
Mo +=(int) num [k] [j];
}
M [j]=mo;
}
return 0;
}
Int deal ()
{
Int a, b, c, d, e;//a 1000 10
\For (int j=0; J & lt; 6; J++)
{
If (m [j] & gt;
=100){
C=m/100 [j];
A=m [j] % 10;
B=(m [j]/10) % 10;
//three digits together the range is 0 to 27, so continue processing
If (a + b + c & lt; 10)
{
M_deal [j]=a + b + c;
}
The else//& gt;=10
{
D=(a + b + c) % 10;
E=(a + b + c)/10;
If (d + e & lt; 10)
{
M_deal [j]=d + e;
}
The else//the only one not to 10 is 19, 1 + 9=10, 1 + 0=1
{
M_deal [j]=1;
}
}
}
The else//& lt; 100
{
D=m [j] % 10;
E=m [j]/10;
If (d + e & lt; 10)
{
M_deal [j]=d + e;
}
The else//the only one not to 10 is 19, 1 + 9=10, 1 + 0=1
{
M_deal [j]=1;
}
}
}
return 0;
}
Int main (int arg c, _TCHAR * argv [])
{
Int No;
Char no [LENTH]={0};
Printf (" please enter the number of data: \ n ");
scanf("%d",& No);
for(int i=0; I & lt; No; I++)
{
Char num_1 [6]={0};//after the superposition of string
Printf (" please enter the first string: % d \ n ", I + 1);
The scanf (" % s ", no);
Int n=0;
For (int j=0; J & lt; 4. J++)
{
int m=0;
While (m & lt; 6)
{
Num [j] [m]=no [n].
M++;
N++;
If (n & gt;=20)//prevent an array
break;
}
}
//test
//for (int I=0; I & lt; 4. I++)
//{
//for (int j=0; J & lt; 6; J++)
//printf (" % c ", num [I] [j]);
//}
Asccii ();
The deal ();
//test
//for (int j=0; J & lt; 6; J++)
//{
//printf (" % d \ n ", m_deal [j]);
//}
For (int j=0; J & lt; 6; J++)
{
Printf (" % d ", m_deal [j]);
}
printf("\n");
//lowercase characters ASCII 97-122, so add up to the ASCII range is 97-122 * 4, namely three or two
}
return 0;
}
CodePudding user response:
How do you so many questions to test?CodePudding user response:
Can I some simple:
#include
Int main ()
{
For (int T=0, I=0, j, k [6]. ! T & amp; & ~ the scanf (" % d ", & amp; T);
For (unsigned char [24] s={0}; I & lt; T & amp; & 24 ~ the scanf (" % s ", s); I++)
{
For (j=0; J & lt; 6; J++)
K [j] [j]=s + s + s + 6 [j] [j] + 12 + s + 18 [j];
For (j=0; J & lt; 6; J++)
While (k [j] & gt; 9) k=k [j]/[j] [j] % 100/10 + 100 + k k [j] % 10;
Printf (" % d % d % d % d % d % d \ n ", k [0], [1], k k [2], [3] k, k [4], [5] k);
}
return 0;
}