Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
BT4B - SO SANH NANG CAO

BT4B - SO SANH NANG CAO

Ratings: (0)|Views: 6 |Likes:
Published by huahongquan2007

More info:

Published by: huahongquan2007 on Apr 04, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

04/04/2011

pdf

text

original

 
C:\Users\Little_Chick\Documents\Visual Studio 2005\Projects\BT4-B\BT4-B\main.cpp Monday, April 04, 2011 2:57 PM
1// Bai 4B: Vi tri cac dong code thay doi , van khac nhau o dau cach va enter , dau tab2// huahongquan20073/*4Gia su file argv[1] = in1.cpp ; argv[2] = in2.cpp5Thuat toan:6- Tao 1 file temp.cpp giong hoan toan voi file ma nguon in2.cpp7- So sanh tung dong cua file in1.cpp voi file temp.cpp8- Neu co dong nao giong nhau thi dong tuong ung cua file temp.cpp se duoc them dau *de ko bi so sanh o lan tiep theo9Moi lan so sanh 1 dong o file1 thi count1 tang len 110Tuong tu cho count2 . Neu count1 = count 2 thi 2 file giong nhau11*/1213#include <stdio.h>14#include <string.h>15boolKiemTra
(
char
* ,
char
*);
16voidCopyFile
(
FILE
*
fpSrc
,
FILE
*
fpDest
);
1718voidmain
(
intargc
,
char
*
argv
[])
19
{
20FILE
*
fp1
=
fopen
(
argv
[
1
],
"rt"
);
21FILE
*
fp2
=
fopen
(
argv
[
2
],
"rt+"
);
22FILE
*
temp
=
fopen
(
"temp1.cpp"
,
"wt+"
);
2324
if(
argc
!=
3
){
25printf
(
"Syntax error : %s <file 1 > < file 2>"
,
argv
[
0
]);
26
}
27
if(
fp1
==NULL) {
28printf
(
"CANNOT OPEN FILE %s \n"
,
argv
[
1
]);
29
return;
30
}
31
if(
fp2
==NULL) {
32printf
(
"CANNOT OPEN FILE %s \n"
,
argv
[
2
]);
33
return;
34
}
35
if(
temp
==NULL) {
36printf
(
"CANNOT OPEN FILE %s \n"
,
argv
[
2
]);
37
return;
38
}
3940CopyFile
(
fp2
,
temp
);
41rewind
(
temp
);
4243chars
[
1024
];
44chars1
[
1024
];
45intcount1
=
0
,
count2
=
0
;
46
while(
fgets
(
s
,
1024
,
fp1
) !=NULL)
47
{
48
if(
s
[
0
] ==
10
)continue;
49
if(
s
[
strlen
(
s
)-
1
] ==
10
)
50s
[
strlen
(
s
)-
1
]=
'\0'
;
51count1
++;
52
while(
fgets
(
s1
,
1024
,
temp
) !=NULL)
53
{
54
if(
s1
[
0
]==
10
)continue;
55
if(
s1
[
strlen
(
s1
)-
1
] ==
10
)
56s1
[
strlen
(
s1
)-
1
]=
'\0'
;
57
-1-

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->