Ó¢ÎÄÎÄÕ¡ª¡ª×Ö·û´®´¦Àí£¨¹²10Ì⣩֮һ
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýSortCharD( ), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»¶Ô×Ö·û°´´Ó´óµ½Ð¡µÄ˳Ðò½øÐÐÅÅÐò, ÅÅÐòºóµÄ½á¹ûÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT2.DATÖС£
Àý: ÔÎÄ: dAe,BfC.
CCbbAA
½á¹û: fedCBA.,
bbCCAA
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void SortCharD(void)
{/**/
int i,j,k,m,n; char ch;
for(i=0; i < maxline; i++)
{ j=strlen(xx[i]);
for(m=0; m < j-1; m++)
{ k=m;
for(n=m+1; n < j; n++)
if(xx[i][k] < xx[i][n]) k=n;
if(k!=m)
{ ch=xx[i][k]; xx[i][k]=xx[i][m]; xx[i][m]=ch; }
}
}
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
SortCharD() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT2.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
in.dat ÎļþÄÚÈÝΪ£º
You can create an index on any field, on several fields to be
used
together, or on parts thereof, that you want to use as a key.
The
keys in indexes allow you quick access to specific records and
define
orders for sequential processing of a ISAM file. After you no
longer
need an index, you can delete it. Addition and indexes have no
effect
on the data records or on other indexes.
You may want a field in field in each record to uniquely
identify that
record from all other records in the file. For example, the
Employee
Number field is unique if you do not assign the same number to
two
different employees, and you never reassign these numbers to
other
employees. If you wish to find or modify the record belonging
to a
specific employee, this unique field saves the thouble of
determining
whether you have the correct record.
If you do not have a unique field, you must find the first
record
the matches your key and determine whether the record is the
one you
want. If it is not the correct one, you must search again to
find others.
If you know that you have a unique field within your records,
you
can include this fact in the key description, and ISAM will
allow only
unique keys. For example, if you specify that the employee
numbers are
unique, ISAM only lets you add records to the file for, or
change
numbers to, employee numbers that do not alreadly exist int
file.
out2.dat ÎļþÄÚÈÝÓ¦µ±Îª£º
yxvuuttsssrroooonnnnnnllliiiffeeeeeeeeeddddccbaaaaaY,
yywuuttttttttsssrrrrpoooooonnkhhhhgfeeeeeeeaaaaaT.,,
yyxwuutssssssrrqpoooonnnnllkkiiiiiiffeeeeeeeeddddccccccaaa
yuuttssssrrrrrrqpooooooonnnnllliiiggffffeeeeeeedcaaSMIAA.
yxxvuttttsooonnnnnnnnliiiiihffeeeeeeeeeeedddddddccaaaaA.,
xtttssrrrrooooonnnihheeeeedddcaa.
yyywuuutttttrrqooonnnnnmllliiiiiiihhfffeeeeeeddddccaaaaaY
yxtttsrrrrrrrppoooooonmmmllllliihhhffeeeeeeeeeeddccaaFE.,
ywuuuuuttttssssrrqooooonnnnmmmliiiiihgffeeeeeeddbbaaN
yyvuuttttsssssrrrrrpoooonnnnnmmliihhgffeeeeeeeeeeeeddbaa,
yyywutttssrrrpoooooooonnnmmlliiiihhggfffeeeeeedddcbaI.
yvuuuttttssssrqppooonnnmmllliiiiiiihhhgfffeeeeeeeeeeeddccba,
ywvutttrrrrrooohhhheeeeeedccca.
yyvuuuuuttttssrrrqooooonnnmliiiihhffffeeeeeddddcaaI,
yyywuuttttttssrrrrroooonnnmmkiihhhhhheeeeeeeeeeeedddccaa
ywuuttttttttssssrrrroooooonnnnnmiiiihhhgffeeeeedcccaaaaI..,
yyyywwvuuuuuutttsrrrqoooooonnnlkiiiihhhffeeeeddcaaaI,
yywwuttttssrpooonnnnnnllllllkiiiiiihhfeeeedddccccaaaaSMIA,
yyyyxuuuutttsssrrrqpppooonnmmmllkiiihhffeeeeeeeeeeecbaaaF.,
yyuuutttssrrrrqoooooonnnllliihhgffeeeeeedddccaaSMIA,,
yyxuuttttttsssrrrpoooonnnnmmmlllliiihfeeeeeeeeddbbaaa.,
×Ö·û´®´¦ÀíÖ®¶þ
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýConvertCharA(), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»°Ñ×Ö·û´®ÖеÄËùÓÐСд×Öĸ¸Äд³É¸Ã×ÖĸµÄÏÂÒ»¸ö×Öĸ, Èç¹ûÊÇ×Öĸz, Ôò¸Äд³É×Öĸa£¬´óд×ÖĸºÍÆäËü×Ö·û±£³Ö²»±ä¡£°ÑÒÑ´¦ÀíµÄ×Ö·û´®ÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT3.DATÖС£
Àý: ÔÎÄ: Adb.Bcdza
abck.LLhj
½á¹û: Aec.Bdeab
bcdl.LLik
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include
#include
#include
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void ConvertCharA(void)
{/**/
int i,j;
for(i=0; i < maxline; i++)
for(j=0; j < strlen(xx[i]); j++)
if(xx[i][j]=='z') xx[i][j]='a';
else if((xx[i][j]>='a')&&(xx[i][j]<'z')) xx[i][j]++;
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
ConvertCharA() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT3.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
out3.datÎļþÄÚÈÝÓ¦µ±ÈçÏ£º
Ypv dbo dsfbuf bo joefy po boz gjfme, po tfwfsbm gjfmet up cf
vtfe
uphfuifs, ps po qbsut uifsfpg, uibu zpv xbou up vtf bt b lfz.
Tif
lfzt jo joefyft bmmpx zpv rvjdl bddftt up tqfdjgjd sfdpset boe
efgjof
psefst gps tfrvfoujbm qspdfttjoh pg b ISAM gjmf. Agufs zpv op
mpohfs
offe bo joefy, zpv dbo efmfuf ju. Aeejujpo boe joefyft ibwf op
fggfdu
po uif ebub sfdpset ps po puifs joefyft.
Ypv nbz xbou b gjfme jo gjfme jo fbdi sfdpse up vojrvfmz
jefoujgz uibu
sfdpse gspn bmm puifs sfdpset jo uif gjmf. Fps fybnqmf, uif
Enqmpzff
Nvncfs gjfme jt vojrvf jg zpv ep opu bttjho uif tbnf ovncfs up
uxp
ejggfsfou fnqmpzfft, boe zpv ofwfs sfbttjho uiftf ovncfst up
puifs
fnqmpzfft. Ig zpv xjti up gjoe ps npejgz uif sfdpse cfmpohjoh
up b
tqfdjgjd fnqmpzff, uijt vojrvf gjfme tbwft uif uipvcmf pg
efufsnjojoh
xifuifs zpv ibwf uif dpssfdu sfdpse.
Ig zpv ep opu ibwf b vojrvf gjfme, zpv nvtu gjoe uif gjstu
sfdpse
uif nbudift zpvs lfz boe efufsnjof xifuifs uif sfdpse jt uif
pof zpv
xbou. Ig ju jt opu uif dpssfdu pof, zpv nvtu tfbsdi bhbjo up
gjoe puifst.
Ig zpv lopx uibu zpv ibwf b vojrvf gjfme xjuijo zpvs sfdpset,
zpv
dbo jodmvef uijt gbdu jo uif lfz eftdsjqujpo, boe ISAM xjmm
bmmpx pomz
vojrvf lfzt. Fps fybnqmf, jg zpv tqfdjgz uibu uif fnqmpzff
ovncfst bsf
vojrvf, ISAM pomz mfut zpv bee sfdpset up uif gjmf gps, ps
dibohf
ovncfst up, fnqmpzff ovncfst uibu ep opu bmsfbemz fyjtu jou
gjmf.
×Ö·û´®´¦ÀíÖ®Èý
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýSortCharA( ), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»¶Ô×Ö·û°´´ÓСµ½´óµÄ˳Ðò½øÐÐÅÅÐò, ÅÅÐòºóµÄ½á¹ûÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT1.DATÖС£
Àý: ÔÎÄ: dAe,BfC.
CCbbAA
½á¹û: ,.ABCdef
AACCbb
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include
#include
#include
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void SortCharA(void)
{/**/
int i,j,k,m,n; char ch;
for(i=0; i < maxline; i++)
{ j=strlen(xx[i]);
for(m=0; m < j-1; m++)
{ k=m;
for(n=m+1; n < j; n++)
if(xx[i][k] > xx[i][n]) k=n;
if(k!=m)
{ ch=xx[i][k]; xx[i][k]=xx[i][m]; xx[i][m]=ch; }
}
}
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
SortCharA() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT1.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
out1.dat ÎļþÄÚÈÝÈçÏÂ(×¢ÒâÿÐеÄÇ°ÃæÓÐÈô¸É¿Õ¸ñ£©£º
,Yaaaaabccddddeeeeeeeeeffiiilllnnnnnnoooorrsssttuuvxy
,,.Taaaaaeeeeeeefghhhhknnooooooprrrrsssttttttttuuwyy
aaaccccccddddeeeeeeeeffiiiiiikkllnnnnoooopqrrsssssstuuwxyy
.AAIMSaacdeeeeeeeffffggiiilllnnnnooooooopqrrrrrrssssttuuy
,.Aaaaaccdddddddeeeeeeeeeeeffhiiiiilnnnnnnnnooosttttuvxxy
.aacdddeeeeehhinnnooooorrrrsstttx
Yaaaaaccddddeeeeeefffhhiiiiiiilllmnnnnnoooqrrtttttuuuwyyy
,.EFaaccddeeeeeeeeeeffhhhiilllllmmmnoooooopprrrrrrrstttxy
Naabbddeeeeeeffghiiiiilmmmnnnnoooooqrrssssttttuuuuuwy
,aabddeeeeeeeeeeeeffghhiilmmnnnnnooooprrrrrsssssttttuuvyy
.Iabcdddeeeeeefffgghhiiiillmmnnnooooooooprrrsstttuwyyy
,abccddeeeeeeeeeeefffghhhiiiiiiilllmmnnnoooppqrssssttttuuuvy
.acccdeeeeeehhhhooorrrrrtttuvwy
,Iaacddddeeeeeffffhhiiiilmnnnoooooqrrrssttttuuuuuvyy
aaccdddeeeeeeeeeeeehhhhhhiikmmnnnoooorrrrrssttttttuuwyyy
,..Iaaaacccdeeeeeffghhhiiiimnnnnnoooooorrrrssssttttttttuuwy
,Iaaacddeeeeffhhhiiiiklnnnooooooqrrrstttuuuuuuvwwyyyy
,AIMSaaaaccccdddeeeefhhiiiiiikllllllnnnnnnoooprssttttuwwyy
,.Faaabceeeeeeeeeeeffhhiiikllmmmnnooopppqrrrssstttuuuuxyyyy
,,AIMSaaccdddeeeeeeffghhiilllnnnooooooqrrrrsstttuuuyy
,.aaabbddeeeeeeeefhiiillllmmmnnnnooooprrrsssttttttuuxyy
×Ö·û´®´¦ÀíÖ®ËÄ
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýStrCharJL( ), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»°Ñ×Ö·û´®ÖеÄËùÓÐ×Ö·ûµÄASCIIÖµ×óÒÆ4λ, Èç¹û×óÒƺó,Æä×Ö·ûµÄASCIIֵСÓÚµÈÓÚ32»ò´óÓÚ100, ÔòÔ×Ö·û±£³Ö²»±ä, ·ñÔò¾Í°Ñ×óÒƺóµÄ×Ö·ûASCIIÖµÔÙ¼ÓÉÏÔ×Ö·ûµÄASCIIÖµ, µÃµ½ÐµÄ×Ö·ûÈÔ´æÈëÔ×Ö·û´®¶ÔÓ¦µÄλÖÃÉÏ£¬Ö®ºó°ÑÒÑ´¦ÀíµÄ×Ö·û´®ÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½OUT7.DATÎļþÖС£
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include
#include
#include
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void StrCharJL(void)
{/**/
int i,j; char m;
/****ÀÏÍõ×¢£º´ËÌâµÄ¹Ø¼üÊǶ¨Òå char m ¡£¼ÇµÃÍùÄêµÄ¿¼ÊÔÀàËÆÌâ¿ÉÒÔ²»±Ø¶¨Ò壬Èç¹ûÒª¶¨ÒåµÄ»°£¬Ôò±ØÐ붨ÒåΪ int ½á¹û²ÅÄÜÕýÈ·¡£¿´À´Àí½â³öÌâÕßµÄÒâͼÊÇ»úÊÔµÄÄѵãÖ®Ò»¡£ ****/
for(i=0; i < maxline; i++)
for(j=0; j < strlen(xx[i]); j++)
{ m=xx[i][j]<<4;
if((m>32)&&(m<=100))
xx[i][j]+=m;
}
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
StrCharJL() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT7.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
×Ö·û´®´¦ÀíÖ®Îå
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýStrCharJR( ), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»°Ñ×Ö·û´®ÖеÄËùÓÐ×Ö·ûµÄASCIIÖµÓÒÒÆ4λ, È»ºó°ÑÓÒÒƺóµÄ×Ö·ûASCIIÖµÔÙ¼ÓÉÏÔ×Ö·ûµÄASCIIÖµ, µÃµ½ÐµÄ×Ö·ûÈÔ´æÈëÔ×Ö·û´®¶ÔÓ¦µÄλÖÃÉÏ£¬Ö®ºó°ÑÒÑ´¦ÀíµÄ×Ö·û´®ÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT8.DATÖС£
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include
#include
#include
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void StrCharJR(void)
{/**/
int i,j;
for(i=0; i
for(j=0; j
xx[i][j]+=xx[i][j]>>4;
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
StrCharJR() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT8.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
out8.dat ÎļþÄÚÈÝÓ¦µ±ÈçÏ£º
^u|"igt"iykg{k"gt"otjk"ut"gt€"lokrj."ut"zk}kygr"lokrjz"{u"hk"|zkj
{umk{nky."uy"ut"wgy{z"{nkykul."{ng{"€u|"~gt{"{u"|zk"gz"g"qk€0"Ynk
qk€z"ot"otjkkz"grru~"€u|"x|oiq"giikzz"{u"zwkioloi"ykiuyjz"gtj"jklotk
uyjkyz"luy"zkx|kt{ogr"wyuikzzotm"ul"g"MXEQ"lork0"El{ky"€u|"tu"rutmky
tkkj"gt"otjk."€u|"igt"jkrk{k"o{0"Ejjo{out"gtj"otjkkz"ng}k"tu"kllki{
ut"{nk"jg{g"ykiuyjz"uy"ut"u{nky"otjkkz0
^u|"sg€"~gt{"g"lokrj"ot"lokrj"ot"kgin"ykiuyj"{u"|tox|kr€"ojkt{ol€"{ng{
ykiuyj"lyus"grr"u{nky"ykiuyjz"ot"{nk"lork0"Juy"kgswrk."{nk"Iswru€kk
R|shky"lokrj"oz"|tox|k"ol"€u|"ju"tu{"gzzomt"{nk"zgsk"t|shky"{u"{~u
jollkykt{"kswru€kkz."gtj"€u|"tk}ky"ykgzzomt"{nkzk"t|shkyz"{u"u{nky
kswru€kkz0"Ml"€u|"~ozn"{u"lotj"uy"sujol€"{nk"ykiuyj"hkrutmotm"{u"g
zwkioloi"kswru€kk."{noz"|tox|k"lokrj"zg}kz"{nk"{nu|hrk"ul"jk{kysototm
~nk{nky"€u|"ng}k"{nk"iuyyki{"ykiuyj0
Ml"€u|"ju"tu{"ng}k"g"|tox|k"lokrj."€u|"s|z{"lotj"{nk"loyz{"ykiuyj
{nk"sg{inkz"€u|y"qk€"gtj"jk{kysotk"~nk{nky"{nk"ykiuyj"oz"{nk"utk"€u|
~gt{0"Ml"o{"oz"tu{"{nk"iuyyki{"utk."€u|"s|z{"zkgyin"gmgot"{u"lotj"u{nkyz0
Ml"€u|"qtu~"{ng{"€u|"ng}k"g"|tox|k"lokrj"~o{not"€u|y"ykiuyjz."€u|
igt"otir|jk"{noz"lgi{"ot"{nk"qk€"jkziyow{out."gtj"MXEQ"~orr"grru~"utr€
|tox|k"qk€z0"Juy"kgswrk."ol"€u|"zwkiol€"{ng{"{nk"kswru€kk"t|shkyz"gyk
|tox|k."MXEQ"utr€"rk{z"€u|"gjj"ykiuyjz"{u"{nk"lork"luy."uy"ingtmk
t|shkyz"{u."kswru€kk"t|shkyz"{ng{"ju"tu{"grykgjr€"koz{"ot{"lork0
×Ö·û´®´¦ÀíÖ®Áù
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýStrOL( ), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»¶ÔÐÐÖÐÒÔ¿Õ¸ñ»ò±êµã·ûºÅΪ·Ö¸ôµÄËùÓе¥´Ê½øÐе¹ÅÅ£¬Í¬Ê±È¥³ý±êµã·ûºÅ£¬Ö®ºó°ÑÒÑ´¦ÀíµÄ×Ö·û´®(Ó¦²»º¬±êµã·ûºÅ)ÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT6.DATÖС£
ÀýÈç: ÔÎÄ: You He Me
I am a student.
½á¹û: Me He You
student a am I
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
**** ͬ1998Äê3BµÚÁùÌâ ****
*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <ctype.h>
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void StrOL(void)
{/**/
int i,j,k,m,n,ll;
char yy[80];
for(i=0; i < maxline; i++)
{ ll=strlen(xx[i]); k=n=0;
for(j=ll-1; j>=0; j--)
{ if(isalpha(xx[i][j])) k++;
else
{ for(m=1; m<=k; m++)
yy[n++]=xx[i][j+m];
k=0;
}
if(xx[i][j]==' ') yy[n++]=' ';
}
for(m=1; m<=k; m++)
yy[n++]=xx[i][j+m];
/* ÉÏÃæÁ½Ðд¦ÀíÿÐеĵÚÒ»¸öµ¥´Ê¡£
Èç¹û©д£¬½á¹ûÏÔÈ»²»ÕýÈ·£¬µ«²¢²»Ó°ÏìµÃ·Ö¡£ */
yy[n]=0;
strcpy(xx[i],yy);
}
/* ±ê×¼´ð°¸Óë´Ë·¨½á¹ûÏà±È£¬Ã¿ÐкóÃæ¶àÒ»¸ö¿Õ¸ñ¡£ */
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
StrOL() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT6.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
out6.dat ÄÚÈÝÓ¦µ±ÈçÏÂ:
used be to fields several on field any on index an create can
You
The key a as use to want you that thereof parts on or together
define and records specific to access quick you allow indexes
in keys
longer no you After file ISAM a of processing sequential for
orders
effect no have indexes and Addition it delete can you index an
need
indexes other on or records data the on
that identify uniquely to record each in field in field a want
may You
Employee the example For file the in records other all from
record
two to number same the assign not do you if unique is field
Number
other to numbers these reassign never you and employees
different
a to belonging record the modify or find to wish you If
employees
determining of thouble the saves field unique this employee
specific
record correct the have you whether
record first the find must you field unique a have not do you
If
you one the is record the whether determine and key your
matches the
others find to again search must you one correct the not is it
If want
you records your within field unique a have you that know you
If
only allow will ISAM and description key the in fact this
include can
are numbers employee the that specify you if example For keys
unique
change or for file the to records add you lets only ISAM
unique
file int exist alreadly not do that numbers employee to
numbers
×Ö·û´®´¦ÀíÖ®Æß
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýConvertCharD(), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»°Ñ×Ö·û´®ÖеÄËùÓÐСд×Öĸ¸Äд³É¸Ã×ÖĸµÄÉÏÒ»¸ö×Öĸ, Èç¹ûÊÇ×Öĸa, Ôò¸Äд³É×Öĸz£¬´óд×ÖĸºÍÆäËü×Ö·û±£³Ö²»±ä¡£°ÑÒÑ´¦ÀíµÄ×Ö·û´®ÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT4.DATÖС£
Àý: ÔÎÄ: Adb.Bcdza
abck.LLhj
½á¹û: Aca.Bbcyz
zabj.LLgi
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void ConvertCharD(void)
{/**/
int i,j;
for(i=0; i < maxline; i++)
for(j=0; j < strlen(xx[i]); j++)
if(xx[i][j]=='a') xx[i][j]='z';
else if(islower(xx[i][j])) xx[i][j]-=1;
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
ConvertCharD() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT4.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
out4.dat ÎļþÄÚÈÝÓ¦µ±ÈçÏÂ:
Ynt bzm bqdzsd zm hmcdw nm zmx ehdkc, nm rdudqzk ehdkcr sn ad
trdc
snfdsgdq, nq nm ozqsr sgdqdne, sgzs xnt vzms sn trd zr z jdx.
Tgd
jdxr hm hmcdwdr zkknv xnt pthbj zbbdrr sn rodbhehb qdbnqcr zmc
cdehmd
nqcdqr enq rdptdmshzk oqnbdrrhmf ne z ISAM ehkd. Aesdq xnt mn
knmfdq
mddc zm hmcdw, xnt bzm cdkdsd hs. Acchshnm zmc hmcdwdr gzud mn
deedbs
nm sgd czsz qdbnqcr nq nm nsgdq hmcdwdr.
Ynt lzx vzms z ehdkc hm ehdkc hm dzbg qdbnqc sn tmhptdkx
hcdmshex sgzs
qdbnqc eqnl zkk nsgdq qdbnqcr hm sgd ehkd. Fnq dwzlokd, sgd
Eloknxdd
Ntladq ehdkc hr tmhptd he xnt cn mns zrrhfm sgd rzld mtladq sn
svn
cheedqdms dloknxddr, zmc xnt mdudq qdzrrhfm sgdrd mtladqr sn
nsgdq
dloknxddr. Ie xnt vhrg sn ehmc nq lnchex sgd qdbnqc adknmfhmf
sn z
rodbhehb dloknxdd, sghr tmhptd ehdkc rzudr sgd sgntakd ne
cdsdqlhmhmf
vgdsgdq xnt gzud sgd bnqqdbs qdbnqc.
Ie xnt cn mns gzud z tmhptd ehdkc, xnt ltrs ehmc sgd ehqrs
qdbnqc
sgd lzsbgdr xntq jdx zmc cdsdqlhmd vgdsgdq sgd qdbnqc hr sgd
nmd xnt
vzms. Ie hs hr mns sgd bnqqdbs nmd, xnt ltrs rdzqbg zfzhm sn
ehmc nsgdqr.
Ie xnt jmnv sgzs xnt gzud z tmhptd ehdkc vhsghm xntq qdbnqcr,
xnt
bzm hmbktcd sghr ezbs hm sgd jdx cdrbqhoshnm, zmc ISAM vhkk
zkknv nmkx
tmhptd jdxr. Fnq dwzlokd, he xnt rodbhex sgzs sgd dloknxdd
mtladqr zqd
tmhptd, ISAM nmkx kdsr xnt zcc qdbnqcr sn sgd ehkd enq, nq
bgzmfd
mtladqr sn, dloknxdd mtladqr sgzs cn mns zkqdzckx dwhrs hms
ehkd.
×Ö·û´®´¦ÀíÖ®°Ë
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýCharConvA( ), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»°Ñ×Ö·û´®ÖеÄ×îºóÒ»¸ö×Ö·ûµÄASCIIÖµÓÒÒÆ4λºó¼Ó×îºóµÚ¶þ¸ö×Ö·ûµÄASCIIÖµ, µÃµ½×îºóÒ»¸öеÄ×Ö·û, ×îºóµÚ¶þ¸ö×Ö·ûµÄASCIIÖµÓÒÒÆ4λºó¼Ó×îºóµÚÈý¸ö×Ö·ûµÄASCIIÖµ,µÃµ½×îºóµÚ¶þ¸öеÄ×Ö·û, ÒÔ´ËÀàÍÆÒ»Ö±´¦Àíµ½µÚ¶þ¸ö×Ö·û, µÚÒ»¸ö×Ö·ûµÄASCIIÖµ¼ÓÔ×îºóÒ»¸ö×Ö·ûµÄASCIIÖµ, µÃµ½µÚÒ»¸öеÄ×Ö·û, µÃµ½µÄÐÂ×Ö·û·Ö±ð´æ·ÅÔÚÔ×Ö·û´®¶ÔÓ¦µÄλÖÃÉÏ£¬Ö®ºó°ÑÒÑ´¦ÀíµÄ×Ö·û´®ÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT10.DATÖС£
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void CharConvA(void)
{/**/
int i,j,ll; char ch;
for(i=0; i < maxline; i++)
{ ll=strlen(xx[i]); ch=xx[i][ll-1];
for(j=ll-1; j; j--)
xx[i][j]=(xx[i][j]>>4)+xx[i][j-1];
xx[i][0]+=ch;
}
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
CharConvA() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT10.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
×Ö·û´®´¦ÀíÖ®9
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýStrOR( ), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»ÒÀ´Î°Ñ×Ö·û´®ÖÐËùÓÐСд×Öĸo ×ó±ßµÄ×Ö·û´®ÄÚÈÝÒƵ½¸Ã´®µÄÓұߴæ·Å, È»ºó²¢°ÑСд×Öĸoɾ³ý,ÓàϵÄ×Ö·û´®ÄÚÈÝÒƵ½ÒÑ´¦Àí×Ö·û´®µÄ×ó±ß´æ·Å£¬Ö®ºó°ÑÒÑ´¦ÀíµÄ×Ö·û´®ÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT5.DATÖС£
ÀýÈç: ÔÎÄ: You can create an index on any field.
you have the correct record.
½á¹û: n any field. Yu can create an index
rd. yu have the crrect rec
ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void StrOR(void)
{/**/
int i,j; char yy[80],*p;
for(i=0; i
for(j=0; j
if(xx[i][j]=='o')
{ p=&xx[i][j+1];
strcpy(yy,p);
strncat(yy,xx[i],j);
strcpy(xx[i],yy);
j=0;
}
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
StrOR() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT5.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
out5.dat ÎļþÄÚÈÝÓ¦µ±ÈçÏ£º
be usedYu can create an index n any field, n several fields t
use as a key. Thetgether, r n parts theref, that yu want t
rds and definekeys in indexes allw yu quick access t specific
rec
ngerrders fr sequential prcessing f a ISAM file. After yu n l
effectneed an index, yu can delete it. Additin and indexes
have n
ther indexes.n the data recrds r n
uniquely identify thatYu may want a field in field in each
recrd t
yeerecrd frm all ther recrds in the file. Fr example, the Empl
Number field is unique if yu d nt assign the same number t tw
therdifferent emplyees, and yu never reassign these numbers t
aemplyees. If yu wish t find r mdify the recrd belnging t
f determiningspecific emplyee, this unique field saves the
thuble
rd.whether yu have the crrect rec
rdIf yu d nt have a unique field, yu must find the first rec
uthe matches yur key and determine whether the recrd is the ne
y
thers.want. If it is nt the crrect ne, yu must search again t
find
uIf yu knw that yu have a unique field within yur recrds, y
nlycan include this fact in the key descriptin, and ISAM will
allw
yee numbers areunique keys. Fr example, if yu specify that the
empl
r changeunique, ISAM nly lets yu add recrds t the file fr,
t alreadly exist int file.numbers t, emplyee numbers that d n
×Ö·û´®´¦ÀíÖ®10
code:
/*
º¯ÊýReadDat( )ʵÏÖ´ÓÎļþIN.DATÖжÁȡһƪӢÎÄÎÄÕ´æÈëµ½×Ö·û´®Êý×éxxÖÐ; Çë±àÖƺ¯ÊýChA( ), Æ亯ÊýµÄ¹¦ÄÜÊÇ: ÒÔÐÐΪµ¥Î»°Ñ×Ö·û´®ÖеĵÚÒ»¸ö×Ö·ûµÄASCIIÖµ¼ÓµÚ¶þ¸ö×Ö·ûµÄASCIIÖµ, µÃµ½µÚÒ»¸öеÄ×Ö·û, µÚ¶þ¸ö×Ö·ûµÄASCIIÖµ¼ÓµÚÈý¸ö×Ö·ûµÄASCIIÖµ,µÃµ½µÚ¶þ¸öеÄ×Ö·û, ÒÔ´ËÀàÍÆÒ»Ö±´¦Àíµ½×îºóµÚ¶þ¸ö×Ö·û, ×îºóÒ»¸ö×Ö·ûµÄASCIIÖµ¼ÓÔµÚÒ»¸ö×Ö·ûµÄASCIIÖµ, µÃµ½×îºóÒ»¸öеÄ×Ö·û, µÃµ½µÄÐÂ×Ö·û·Ö±ð´æ·ÅÔÚÔ×Ö·û´®¶ÔÓ¦µÄλÖÃÉÏ£¬Ö®ºó°ÑÒÑ´¦ÀíµÄ×Ö·û´®ÄæתºóÈÔ°´ÐÐÖØдæÈë×Ö·û´®Êý×éxxÖС£×îºómain()º¯Êýµ÷Óú¯ÊýWriteDat()°Ñ½á¹ûxxÊä³öµ½ÎļþOUT9.DATÖС£ÔʼÊý¾ÝÎļþ´æ·ÅµÄ¸ñʽÊÇ: ÿÐеĿí¶È¾ùСÓÚ80¸ö×Ö·û, º¬±êµã·ûºÅºÍ¿Õ¸ñ¡£
×¢Òâ: ²¿·ÖÔ´³ÌÐò´æ·ÅÔÚPROG1.CÖС£
ÇëÎð¸Ä¶¯Ö÷º¯Êýmain( )¡¢¶ÁÊý¾Ýº¯ÊýReadDat()ºÍÊä³öÊý¾Ýº¯ÊýWriteDat()µÄÄÚÈÝ¡£
*/
#include <stdio.h>
#include <string.h>
#include <conio.h>
char xx[50][80] ;
int maxline = 0 ; /* ÎÄÕµÄ×ÜÐÐÊý */
int ReadDat(void) ;
void WriteDat(void) ;
void ChA(void)
{/**/
int i,j; char ch;
for(i=0; i < maxline; i++)
{ ch=xx[i][0];
for(j=0; j < strlen(xx[i])-1; j++)
xx[i][j]+=xx[i][j+1];
xx[i][j]+=ch;
strrev(xx[i]);
}
/**/
}
void main()
{
clrscr() ;
if(ReadDat()) {
printf("Êý¾ÝÎļþIN.DAT²»ÄÜ´ò¿ª!\n\007") ;
return ;
}
ChA() ;
WriteDat() ;
}
int ReadDat(void)
{
FILE *fp ;
int i = 0 ;
char *p ;
if((fp = fopen("IN.DAT", "r")) == NULL) return 1 ;
while(fgets(xx[i], 80, fp) != NULL) {
p = strchr(xx[i], '\n') ;
if(p) *p = 0 ;
i++ ;
}
maxline = i ;
fclose(fp) ;
return 0 ;
}
void WriteDat(void)
{
FILE *fp ;
int i ;
clrscr() ;
fp = fopen("OUT9.DAT", "w") ;
for(i = 0 ; i < maxline ; i++) {
printf("%s\n", xx[i]) ;
fprintf(fp, "%s\n", xx[i]) ;
}
fclose(fp) ;
}
±±¾© | Ìì½ò | ÉϺ£ | ½ËÕ | ɽ¶« |
°²»Õ | Õã½ | ½Î÷ | ¸£½¨ | ÉîÛÚ |
¹ã¶« | ºÓ±± | ºþÄÏ | ¹ãÎ÷ | ºÓÄÏ |
º£ÄÏ | ºþ±± | ËÄ´¨ | ÖØÇì | ÔÆÄÏ |
¹óÖÝ | Î÷²Ø | н® | ÉÂÎ÷ | ɽÎ÷ |
ÄþÏÄ | ¸ÊËà | Çຣ | ÁÉÄþ | ¼ªÁÖ |
ºÚÁú½ | ÄÚÃɹŠ|