• 2021-04-14
    编写一个函数,输入一个字符串判断是否是回文串,判定规则是前后字符都相等,如”abcba”,是回文输出”yes.”,不是输出”no.”。 #include #include using namespace std; bool pString(char str[]); int main() { char s[81]; gets(s); if(pString(s))cout<=j)return true; else return false; }
  • strlen(str)  str[j]

    内容

    • 0

      下面的程序功能是:用 getchar() 输入一个字符,再用 putchar()将其 输出。 #include int main() { char ch; ① ; ② ; return 0; }

    • 1

      中国大学MOOC:"Squeeze函数的功能是删除字符串s中所出现的与变量c相同的字符。例如,输入为:abcdef↙c↙输出为:abdef按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。#include #include void Squeeze(char *s, char c); int main() { char a[80], c, *s; s = a; gets(a); scanf("%c",&c); Squeeze(s, c); printf("%s ", s); return 0; } void Squeeze(char *s, char c) { int i, j; for (i = j = 0; s[i] != ''; i++) { if (__________) { __________; j++; } } _____________; /* 在字符串t2的末尾添加字符串结束标志 */ }";

    • 2

      将字符串中的数字字符删除后输出。 #include "stdio.h" void delnum(char s[]) { int i,j; for(i=0,j=0;【1】;i++) if(s[i]<'0' 【2】 s[i]>'9') { s[j]=s[i]; j++; } 【3】; } main() { char item[50]; gets(item); 【4】; printf("%s ",item); }

    • 3

      删除字符串的所有前导空格,请完善程序。 #include <stdio.h> void f1(char *s) { char *t; t= ________ ; while(*s==) s++; while(*t++=*s++); } int main( ) { char str&#91;80&#93;; gets(str); f1(str); puts(str); return 0; } 得分/总分

    • 4

      中国大学MOOC: 下面程序执行后的输出结果是:#include <iostream>using namespace std;void fun(char *c,char d){*c=*c+1; d=d+1;cout<<*c<<","<<d<<",";}int main(){char a=A, b=a;fun(&b,a); cout<<a<<","<<b<<endl;return 0;}