用c语言编写文字分类程序(从文件读入)

用c语言编写文字分类程序(从文件读入),第1张

#include<stdio.h>

#include<stdlib.h>

main()

{

FILE *fp

int a,j,l

int flag

int s[a-1]

char i[a-1]

char k[a-1]

float pct[a-1]

char c

a=0

if ((fp=fopen("c:\\1.txt","r"))==NULL)

{printf ("can`t open")

exit(0)}

for (j=0!feof(fp)j++)

{

a++

c=fgetc(fp)

i[j]=c

k[j]= c

printf ("%c",c)

s[j]=0

pct[j]=0.0

}

printf ("\n共有塌禅绝%d个字符",a-1)

for (l=0l<(a-1)l++)

{

for (j=0j<(a-1)j++)

{ if (k[l]==i[j])

{ s[l]++}

}

}

printf("\nchar number percent\n")

for (l=0l<(a-1)l++)

{ flag=1

for (j=lj<=(a-1)j++)

{if (i[j]==i[l]&&l!=j)

{ flag=0

continue

}

}

if (flag!=0)

{

printf("%2c %6d \t\n",i[l],s[l])

}

}

}

C:\>团姿"C:\Documents and Settings\Administrator\桌面\未命名1.exe"袭蠢

abcdlllleaocmezl�

共有16个字符

char number percent

b 1

d 1

a 2

o 1

c 2

m 1

e 2

z 1

l 5

实现了一部分,希望哪位朋友可以帮你完善

T

W DW2009H

NUM DB00H

DATASG ENDS

CODESG SEGMENT

ASSUMEDS:DATASG,CS:CODESG

START:

MOV AX,DATASG

MOV DS,AX

MOV AX,W

CLC

MOV CX,16

AGAIN:

RCR AX,1

JCISONE

JMP EXIT

ISONE:

INC NUM

EXIT:

LOOP AGAIN

MOV AX,4C00H

INT 21H

CODESG ENDS

END START

2.

DATASG SEGMENT

X DB-10,0,10

Y DB3 DUP(?)

DATASG ENDS

CODESG SEGMENT

ASSUMEDS:DATASG,CS:CODESG

START:

MOV AX,DATASG

MOV DS,AX

MOV CX,03H

MOV SI,00H

AGAIN:

MOV AL,X[SI]

CMP AL,00H

JZISZERO

TEST AL,80H

JZISPOS

MOV Y[SI],-1

JMP EXIT

ISZERO:

MOV Y[SI],0

JMP EXIT

ISPOS:

MOV Y[SI],1

EXIT:

INC SI

LOOP AGAIN

MOV AX,4C00H

INT 21H

CODESG ENDS

END START


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12395886.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存