摘要: 1 /*for(i = 0; i = lim - 1) /* outside of valid range ?*/ 6 okloop = NO; 7 else if ((c = getchar()) == '\n') 8 okloop = NO; 9 else if(c == EOF)/*end of file ?*/10 okloop = NO;11 else{s[i] = c12 ++i13 }目测差不多!还是我的答案不行? 阅读全文
posted @ 2013-10-29 16:11 _Jango 阅读(719) 评论(0) 推荐(0) 编辑
摘要: 不太了解如何打印取值范围。直接看答案。通过打印头文件实现 1 #include 2 #include 3 main() 4 { 5 /* signed types */ 6 7 printf("signed char min = %d\n", SCHAR_MIN); 8 printf("signed char max = %d\n", SCHAR_MAX); 9 printf("signed short min = %d\n", SHRT_MIN);10 printf("signed short max = %d\n&quo 阅读全文
posted @ 2013-10-28 22:14 _Jango 阅读(1741) 评论(0) 推荐(0) 编辑
摘要: 大概能理解题目意思,程序需要检测,输入的内容中,括号对等(检测到头括号,必须要检测到尾括号对应,否则报错),引号对称等处理内容。 1 #include 2 3 int brace, brack, paren; 4 5 void in_quote(int c); 6 void in_comment(viod); 7 void search(int c); 8 9 /* rudimentary syntax checker for C programs*/10 11 main()12 {13 int c;14 extern int brace, brack, paren;1... 阅读全文
posted @ 2013-10-27 16:41 _Jango 阅读(1091) 评论(0) 推荐(0) 编辑
摘要: 由于没能理解题目意思 ,直接看看答案。 1 #include 2 3 4 void rcomment(int c); 5 void in_comment(void); 6 void echo_quote(int c); 7 8 /* remove all comment form a valid C program*/ 9 10 11 main()12 {13 int c, d;14 while ((c = getchar()) != EOF)15 16 rcomment(c);17 return 0;18 }19 20 21 /* rcomment : rea... 阅读全文
posted @ 2013-10-27 15:14 _Jango 阅读(1168) 评论(0) 推荐(0) 编辑
摘要: 题目理解:自定义n为行的极限长度,输入行超过n列则进行折行操作,并且需要每列的开头不能是空格和制表符例如n = 3 输入 aaaa 则输出 aaa a在有空格和制表符的情况输入 aaa空格空格制表符制表符a 输出 aaa a(不带空格和制表符)。我的答案: 1 #include 2 #define LINEN 2 /*设置折行位置字符*/ 3 4 main() 5 { 6 int c, pos; 7 pos = 1;/*当前输入位置*/ 8 while((c = getchar()) != EO... 阅读全文
posted @ 2013-10-25 23:11 _Jango 阅读(756) 评论(0) 推荐(0) 编辑
摘要: 制表符终止位,不太懂这个东西.google得知是空格代替制表符 1 #include 2 #define TABINC 8 3 4 main() 5 { 6 int c, nb, nt, pos; 7 nb = 0; 8 nt = 0; 9 for(pos = 1; (c = getchar()) != EOF; ++pos)10 if(c == ' ')11 {12 if(pos % TABINC != 0)13 ++nb;14 else15 {16 ... 阅读全文
posted @ 2013-10-25 20:57 _Jango 阅读(1125) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #define TABINC 8 3 4 main() 5 { 6 int c, nb, pos; 7 nb = 0; 8 pos = 1; 9 while((c = getchar())!= EOF)10 {11 if(c =='\t')12 {13 nb = TABINC - (pos - 1) % TABINC;14 while (nb > 0)15 {16 putchar(' ');17 ++pos;18 --nb;19 }20 }else if(c == '\n')21 {22 putchar(c);23 阅读全文
posted @ 2013-10-25 20:26 _Jango 阅读(662) 评论(0) 推荐(0) 编辑
摘要: 看答案 1 #include 2 #define MAXLINE 1000 //允许输入行的最大长度 3 #define LONGLINE 80 4 5 int getline(char line[], int maxline); 6 7 int removes(char s[]); 8 9 main()10 {11 char line[MAXLINE];12 while(getline(line, MAXLINE) > 0)13 if(removes(line) > 0)14 printf("%s", line);15 return 0;16 }17 // g 阅读全文
posted @ 2013-10-25 13:43 _Jango 阅读(1047) 评论(0) 推荐(0) 编辑
摘要: 依然是看答案 1 #include 2 #define MAXLINE 1000 //允许输入行的最大长度 3 #define LONGLINE 80 4 5 int getline(char line[], int maxline); 6 7 // print lines longer than LONGLINE 8 main() 9 {10 int len;11 char line[MAXLINE];12 13 while((len - getline(line, MAXLINE)) > 0)14 if(len > LONGLINE)15 printf("%S&quo 阅读全文
posted @ 2013-10-22 13:35 _Jango 阅读(860) 评论(0) 推荐(0) 编辑
摘要: 先粘贴一遍原程序, 在此基础上改改看。#include #define MAXLINE 1000 //允许输入行的最大长度int getline(char line[], int maxline);void copy(char to[], char from[]);//打印最长的输入行main(){ int len; //当前行长度 int max; //目前为止发现的最长行的长度 char line[MAXLINE]; //当前的输入行 char longest[MAXLIN... 阅读全文
posted @ 2013-10-21 00:21 _Jango 阅读(1005) 评论(0) 推荐(0) 编辑