组合多个块:检查字母表,检查字符串长度,检查是否回文

时间:2016-12-06 13:02:06

标签: c

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define FALSE 0
#define TRUE 1

if (strcmp(strrev(inputarray),temp) == 0) {
        printf("Palindrome\n");
    } else {
        printf("Not palindrome\n");
    }
}

我正在尝试编写程序来提示用户输入字符串: ............... iii)检查字符串是否是回文,如果是,则输出回文,如果不是,则不是回文

当我测试零件时,效果很好。

将它们全部组合起来时,即使它出现输出'也不是回文'。我做错了什么?

3 个答案:

答案 0 :(得分:2)

您永远不会初始化<flow name="csv-source-inputFlow_Clean_etoc"> <vm:inbound-endpoint exchange-pattern="one-way" path="validRecordsEtoc" doc:name="VM_TFO_ETOC_SUBS_SRC"/> <enricher doc:name="Enrich inbound Message Properties"> <logger message="Etoc source message enricher : BatchId : #[message.inboundProperties.flow_batch_id] Total Records : #[message.inboundProperties.totalRecordCount] Successful Records : #[message.inboundProperties.successRecordCount]" level="INFO" doc:name="Logger"/> <enrich source="#[message.inboundProperties.'flow_batch_id']" target="#[flowVars.flow_batch_id]"/> <enrich source="#[message.inboundProperties.'flow_source_name']" target="#[flowVars.flow_source_name]"/> <enrich source="#[message.inboundProperties.'successRecordCount']" target="#[flowVars.successRecordCount]"/> <enrich source="#[message.inboundProperties.'totalRecordCount']" target="#[flowVars.totalRecords]"/> <enrich source="#[message.inboundProperties.'input_file_name']" target="#[flowVars.input_file_name]"/> </enricher> <batch:execute name="csv-source-inputBatch_ETOC" doc:name="csv-source-inputBatch_ETOC"/> </flow> <batch:job name="csv-source-inputBatch_ETOC"> <batch:input> <set-payload value="#[payload]" doc:name="Set Payload_TFO_ETOC"/> </batch:input> <batch:process-records> <batch:step name="TFOETOC_CLEAN_Batch_Step"> <batch:commit size="2000" doc:name="TFO_ETOC Clean Batch Commit"> <db:insert config-ref="LocalhostPostgres" bulkMode="true" doc:name="Enrich_TFO_ETOC_Src_Data"> <db:parameterized-query><![CDATA[INSERT INTO public."csv_tfo_3.4.1 etoc subs"( seq_id, batch_id, publication, code, first_name, last_name,subscription_date, email, marketable , organization, department, address1 , address2, city, state, zip_code, country, phone, status, source) values (DEFAULT,#[flowVars.flow_batch_id],#[payload.Publication] , #[payload.Code] , #[payload.First_Name],#[payload.Last_Name], to_timestamp(#[payload.Subscription_Date],'yyyy-mm-dd hh24:mi:ss'),#[payload.Email],#[payload.Marketable],#[payload.Organization],#[payload.Department],#[payload.Address1],#[payload.Address2],#[payload.City],#[payload.State],#[payload.Zip_Code],#[payload.Country],#[payload.Phone],'pending','TFO')]]></db:parameterized-query> </db:insert> </batch:commit> </batch:step> </batch:process-records> </batch:job> 。 在做temp之前strcmp

答案 1 :(得分:0)

你有printf(&#34;%s请输入字符串&gt;&#34;); 这可能会导致损坏,请在从此printf语句中删除%s后尝试

答案 2 :(得分:0)

尝试使用此作为你的回文函数而不是strrev(这不是标准C)。我注意到,当我尝试使用strcmp(strrev(str), str)==0)来测试回文时,我总是得到&#34;是回文&#34;太

int ispalindrome(char *str, int len)
{   
    char *p = &str[0];
    char *q = &str[len - 1];
    do
    {
        if(p >= q)
        {
            return 1;
        }
    } while (*p++ == *q--);
    return 0;
}