早教吧 育儿知识 作业答案 考试题库 百科 知识分享

谁知道这个program该怎么写?THX!WriteaCprogramtoimplementasimplechecksumfunctionforasinglelineofinput(i.e.,endswith'n').Thechecksumisdonebymultiplyingtheasciicodeofeachinputcharacterwithdigit1,2,3,...,9,1,2,3,.

题目详情
谁知道这个program该怎么写?THX!
Write a C program to implement a simple check sum function for a single line
of input (i.e.,ends with 'n').The check sum is done by multiplying the ascii code of each input characterwith digit 1,2,3,...,9,1,2,3,...and sum up the result.The \x0cnal total is the\check sum" we are looking for.For example,for the input line "This is a sample input line of text",its
check sum is calculated by
T h i s i s a s a m p ...
1 2 3 4 5 6 7 8 9 1 2 3 4 5 ...
Then the check sum is
84x1+104x2+105x3+115x4+32x5+105x6+115x7+32x8+97x9+32x1+115x2+97x3+109x4+:::
Your program should find and display the check sum of the input text.
▼优质解答
答案和解析
nt i; for(i = 2; i < m/2; i++) { if(0 == m%i) { printf("%d x ", i); get(m/i); return; } } printf("%d \n...