高手帮忙些个c程序

来源:百度知道 编辑:UC知道 时间:2024/05/18 14:31:44
请问这个程序谁会写?帮帮忙~~~~~急
密码是一个数字串,例如,以下是两条密码:
第一条:7.21, 7, 17, 6.7.1,13, 19, 10, 2.18, 25, 9, 3.25, 18, 16, 7, 14.18, 13.18, 6, 3.11, 13, 13, 12, -2
第二条:12, 20.8, 23, 16, 1, 1.18, 4, 2, 20.16, 9.8, 24.13, 15
破译原则如下:
1) 每个数字串的最后一个数为密码钥匙(它不是密码原文),设为key。每个数表示译文中的一个大写英文字母,用这些数减去key后所得到的值经适当修改后,为大写英文字母的相应序号。例如,相减后的值为1,对应的字母为A。修正方法为:①若相减后的值小于或等于零,则将其加上26。②若相减后的值大于26(当Key为负数时),则将其减去26。
2) 密码中的逗号为数字间的分隔符,密码中的圆点既是数字间的分隔符又代表译文中的空格。
假如一个密码为16,9.8,24,13,15
按照上述原则破译结果为“AT SIX”
将任给的若干条密码存入数据文件IN.DAT,设计程序,按上面的方法逐个进行破译。输出破译结果,并将结果输出到文件OUT.DAT中。

#include <stdio.h>
#include <string.h>
#define FILENAME_in "e:\input.dat" /*here to change the file adress*/
#define FILENAME_out "e:\output.dat" /*here to change the file adress*/

void transact(void)
{
FILE *fp;
int data_long,i=0,j=0,k=0,n=0;
int temp=0;
char s_data[64]="";
char data_end[32]="";
int data_num[64]={0};
char data_temp[64]="";

if ((fp=fopen(FILENAME_in,"r"))==NULL)
{
printf("cannot open file\n");
return;
}
fread(s_data,sizeof (s_data),1,fp);
fclose(fp);

data_long=strlen(s_data);
for(i = 0; i < data_long; i++)/*here to transact the data*/
{
if (s_data[i]>='0'&&s_data[i]<='9')
{
data_num[j]=(s_data[i]-48)+data_num[j]*10;
}
else if (s_data[i]==',')
{