資源簡(jiǎn)介
C和指針(pdf是高清掃秒版,完整版,還附有講解代碼)
代碼片段和文件信息
/*
**?This?program?reads?input?lines?from?the?standard?input?and?prints
**?each?input?line?followed?by?just?some?portions?of?the?lines?to
**?the?standard?output.
**
**?The?first?input?is?a?list?of?column?numbers?which?ends?with?a
**?negative?number.??The?column?numbers?are?paired?and?specify
**?ranges?of?columns?from?the?input?line?that?are?to?be?printed.
**?For?example?0?3?10?12?-1?indicates?that?only?columns?0?through?3
**?and?columns?10?through?12?will?be?printed.
*/
#include?
#include?
#include?
#define MAX_COLS 20 /*?max?#?of?columns?to?process?*/
#define MAX_INPUT 1000 /*?max?len?of?input?&?output?lines?*/
int read_column_numbers(?int?columns[]?int?max?);
void rearrange(?char?*output?char?const?*input
????int?n_columns?int?const?columns[]?);
int
main(?void?)
{
int n_columns; /*?#?of?columns?to?process?*/
int columns[MAX_COLS]; /*?the?columns?to?process?*/
char input[MAX_INPUT]; /*?array?for?input?line?*/
char output[MAX_INPUT]; /*?array?for?output?line?*/
/*
**?Read?the?list?of?column?numbers
*/
n_columns?=?read_column_numbers(?columns?MAX_COLS?);
/*
**?Read?process?and?print?the?remaining?lines?of?input.
*/
while(?gets(?input?)?!=?NULL?){
printf(?“Original?input?:?%s\n“?input?);
rearrange(?output?input?n_columns?columns?);
printf(?“Rearranged?line:?%s\n“?output?);
}
return?EXIT_SUCCESS;
}
/*
**?Read?the?list?of?column?numbers?ignoring?any?beyond?the?specified
**?maximum.
*/
int
read_column_numbers(?int?columns[]?int?max?)
{
int num?=?0;
int ch;
/*
**?Get?the?numbers?stopping?at?eof?or?when?a?number?is?0.
*/
while(?num? ????&&?columns[num]?>=?0?)
num?+=?1;
/*
**?Make?sure?we?have?an?even?number?of?inputs?as?they?are
**?supposed?to?be?paired.
*/
if(?num?%?2?!=?0?){
puts(?“Last?column?number?is?not?paired.“?);
exit(?EXIT_FAILURE?);
}
/*
**?Discard?the?rest?of?the?line?that?contained?the?final
**?number.
*/
while(?(ch?=?getchar())?!=?EOF?&&?ch?!=?‘\n‘?)
;
return?num;
}
/*
**?Process?a?line?of?input?by?concatenating?the?characters?from
**?the?indicated?columns.??The?output?line?is?then?NUL?terminated.
*/
void
rearrange(?char?*output?char?const?*input
????int?n_columns?int?const?columns[]?)
{
int col; /*?subscript?for?columns?array?*/
int output_col; /*?output?column?counter?*/
int len; /*?length?of?input?line?*/
len?=?strlen(?input?);
output_col?=?0;
/*
**?Process?each?pair?of?column?numbers.
*/
for(?col?=?0;?col? int nchars?=?columns[col?+?1]?-?columns[col]?+?1;
/*
**?If?the?input?line?isn‘t?this?long?or?the?output
**?array?is?full?we‘re?done.
*/
if(?columns[col]?>=?len?||
????output_col?==?MAX_INPUT?-?1?)
break;
/*
**?If?there?isn‘t?room?in?the?output?array?only?copy
**?what?will?fit.
*/
if(?output_col?+?ncha
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????????0??2017-11-01?10:50??C鍜屾寚閽?
?????文件????????6148??2018-01-22?14:44??C鍜屾寚閽?.DS_Store
?????目錄???????????0??2018-01-29?20:06??__MACOSX\
?????文件???????????0??2018-01-29?20:06??__MACOSX\C鍜屾寚閽?
?????文件?????????120??2018-01-22?14:44??__MACOSX\C鍜屾寚閽?._.DS_Store
?????文件????29967827??2015-03-15?18:55??C鍜屾寚閽?C鍜屾寚閽?pdf
?????文件?????????223??2015-03-15?18:55??__MACOSX\C鍜屾寚閽?._C鍜屾寚閽?pdf
?????文件???????????0??2017-11-01?10:50??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?
?????文件????????6148??2018-01-22?14:44??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?.DS_Store
?????文件???????????0??2018-01-29?20:06??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?
?????文件?????????120??2018-01-22?14:44??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?._.DS_Store
?????目錄???????????0??2018-01-05?17:31??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\
?????目錄???????????0??2009-04-03?23:10??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch9\
?????文件?????????397??1997-06-20?11:45??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch9\token.c
?????目錄???????????0??2018-01-29?20:06??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\
?????目錄???????????0??2018-01-29?20:06??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch9\
?????文件?????????223??1997-06-20?11:45??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch9\._token.c
?????文件?????????882??1997-06-20?11:45??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch9\mstrrstr.c
?????文件?????????223??1997-06-20?11:45??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch9\._mstrrstr.c
?????文件?????????214??1997-06-20?11:45??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch9\strlen.c
?????文件?????????223??1997-06-20?11:45??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch9\._strlen.c
?????文件?????????187??2009-04-03?23:10??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\._ch9
?????目錄???????????0??2009-04-03?23:10??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\
?????文件?????????437??1997-06-20?11:45??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\find_int.c
?????目錄???????????0??2018-01-29?20:06??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\
?????文件?????????223??1997-06-20?11:45??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\._find_int.c
?????文件?????????342??1997-06-20?11:45??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\average1.c
?????文件?????????223??1997-06-20?11:45??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\._average1.c
?????文件?????????376??1997-06-20?11:45??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\fib_iter.c
?????文件?????????223??1997-06-20?11:45??__MACOSX\C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\._fib_iter.c
?????文件?????????344??1997-06-20?11:45??C鍜屾寚閽?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀錛誨畬鏁寸増錛?c鍜屾寚閽堜唬鐮佸強(qiáng)絳旀\ch7\clrarray.c
............此處省略256個(gè)文件信息
- 上一篇:麥克風(fēng)陣列的波束形成
- 下一篇:visio模具.zip
評(píng)論
共有 條評(píng)論