exercise1-18

Write a program to remove trailing blanks and tabs from each line of input,and to delete entirely blank lines.

1、各种常用键的ASCII码值是多少,参见网页:查看常用键的ASCII码值

空格:32

制表:9


………………………………………………………………………………………………………………………………………………………

#include<stdio.h>
#define MAXLINE 1000


int getlines(char line[],int maxline);
int removes(char s[]);


/*print the new input line*/
main()
{
        char line[MAXLINE];


        while(getlines(line,MAXLINE)>0)
          if(removes(line)>0)
                printf("%s",line);
        return 0;
}


int getlines(char s[],int lim)
{
        int c,i;


        for(i=0;i<lim-1 && (c= getchar()) != EOF && c!='\n';++i)
                s[i]= c;

        if ( c =='\n')

       {

                s[i] = c;

                    ++i;

       }
        
        s[i] = '\0';
        return i;
}


int removes(char s[])
{
        int i;


        i = 0;
        while(s[i] != '\n')
        ++ i;
        i = i-1;


        while(i >= 0 && (s[i] == ' '||s[i] == '\t'))
        --i;


        if(i>=0){
        ++ i;
        s[i] = '\n';
        ++ i;
        s[i] = '\0';

       }

       return i;

}




delete.c

这一题目当时理解有误,以为是删除单词之间的多余空格和tab键,后来才明白题目要求很简单,trailing blanks是指输入结束后,文本末尾多余的空格和tab键。

NOTE:绝对不能自以为是,或许有些时候就是简单的理解偏差而已。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
2023-06-06 18:10:33,041 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7 2023-06-06 18:10:33,075 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead. 2023-06-06 18:10:33,218 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset. 2023-06-06 18:10:33,218 INFO tool.CodeGenTool: Beginning code generation Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. 2023-06-06 18:10:33,782 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `user_log` AS t LIMIT 1 2023-06-06 18:10:33,825 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `user_log` AS t LIMIT 1 2023-06-06 18:10:33,834 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/module/hadoop-3.1.4 注: /tmp/sqoop-root/compile/5f4cfb16d119de74d33f1a0d776d5ae0/user_log.java使用或覆盖了已过时的 API。 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 2023-06-06 18:10:35,111 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/5f4cfb16d119de74d33f1a0d776d5ae0/user_log.jar 2023-06-06 18:10:35,125 WARN manager.MySQLManager: It looks like you are importing from mysql. 2023-06-06 18:10:35,126 WARN manager.MySQLManager: This transfer can be faster! Use the --direct 2023-06-06 18:10:35,126 WARN manager.MySQLManager: option to exercise a MySQL-specific fast path. 2023-06-06 18:10:35,126 INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql) 2023-06-06 18:10:35,130 ERROR tool.ImportTool: Import failed: No primary key could be found for table user_log. Please specify one with --split-by or perform a sequential import with '-m 1'.
最新发布
06-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值