C语言 数组 输入一行文字,要求将每个单词的首字母由小写改为大写,单词间用空格隔开 C语言编程:输入一个英文句子(全为小写),将句中每个单词的末...

\uff08C\u8bed\u8a00\u7f16\u7a0b\uff09\u8f93\u5165\u4e00\u4e2a\u82f1\u6587\u53e5\u5b50\uff0c\u5c06\u6bcf\u4e2a\u82f1\u6587\u5355\u8bcd\u7684\u5934\u5b57\u6bcd\u53d8\u4e3a\u5927\u5199\uff0c\u5355\u8bcd\u4e4b\u95f4\u7528\u7a7a\u683c\u9694\u5f00

\u7a0b\u5e8f\u5df2\u5728dev-c++\u4e0b\u7f16\u8bd1\u786e\u8ba4\uff1a/*\u63d0\u53d6\u7528\u7a7a\u683c\u5206\u9694\u7684\u5b57\u7b26\u4e32\u4e2d\u7684\u5355\u8bcd\uff0c\u5e76\u6539\u5355\u8bcd\u9996\u5b57\u6bcd\u4e3a\u5927\u5199*/
#include
int partition(char *s1,char *s2,int pos)
{
int i,j;
i=pos;
while(s1[i]==' ')
i++;
if(s1[i]!='\0')
{
j=0;
s2[j]='\0';
s2[0]=toupper(s2[0]);
return i;
char string[256];
char partition_string[20];
int position;
int k;
printf("\nPlease input a string:");
printf("\n");
system("pause");
return 0;
}

\u7b80\u6d01\u7684\u8bed\u8a00
C\u8bed\u8a00\u5305\u542b\u7684\u5404\u79cd\u63a7\u5236\u8bed\u53e5\u4ec5\u67099\u79cd\uff0c\u5173\u952e\u5b57\u4e5f\u53ea\u670932\u4e2a\uff0c\u7a0b\u5e8f\u7684\u7f16\u5199\u8981\u6c42\u4e0d\u4e25\u683c\u4e14\u4ee5\u5c0f\u5199\u5b57\u6bcd\u4e3a\u4e3b\uff0c\u5bf9\u8bb8\u591a\u4e0d\u5fc5\u8981\u7684\u90e8\u5206\u8fdb\u884c\u4e86\u7cbe\u7b80\u3002\u5b9e\u9645\u4e0a\uff0c\u8bed\u53e5\u6784\u6210\u4e0e\u786c\u4ef6\u6709\u5173\u8054\u7684\u8f83\u5c11\uff0c\u4e14C\u8bed\u8a00\u672c\u8eab\u4e0d\u63d0\u4f9b\u4e0e\u786c\u4ef6\u76f8\u5173\u7684\u8f93\u5165\u8f93\u51fa\u3001\u6587\u4ef6\u7ba1\u7406\u7b49\u529f\u80fd\uff0c\u5982\u9700\u6b64\u7c7b\u529f\u80fd\uff0c\u9700\u8981\u901a\u8fc7\u914d\u5408\u7f16\u8bd1\u7cfb\u7edf\u6240\u652f\u6301\u7684\u5404\u7c7b\u5e93\u8fdb\u884c\u7f16\u7a0b\uff0c\u6545c\u8bed\u8a00\u62e5\u6709\u975e\u5e38\u7b80\u6d01\u7684\u7f16\u8bd1\u7cfb\u7edf\u3002
\u4ee5\u4e0a\u5185\u5bb9\u53c2\u8003\uff1a\u767e\u5ea6\u767e\u79d1-c\u8bed\u8a00

\u7b80\u5355\u70b9\u7528\u6570\u7ec4\u3002
\u7528\u6307\u9488\u6307\u51fa\u4e24\u4e2a\u4f4d\u7f6e\uff0c\u4e00\u4e2a\u63070\uff0c\u4e00\u4e2a\u63071\u3002
{
\u5f53\u6307\u540e\u9762\u4f4d\u7f6e\u7684\u5b57\u7b26\u4e0d\u4e3a\u7a7a\u683c\u65f6\uff0c\u4e24\u4e2a\u6307\u9488\u4f4d\u7f6e\u90fd\u52a01\u3002
\u5982\u679c\u6307\u540e\u9762\u4f4d\u7f6e\u7684\u5b57\u7b26\u4e3a\u7a7a\u683c\u65f6\uff0c\u524d\u4e00\u4f4d\u7f6e\u7684\u5b57\u7b26ASCII-32\uff0c\u7136\u540e\u4e24\u4e2a\u6307\u9488\u4f4d\u7f6e\u90fd\u52a01\u3002
}
\u4ee5\u4e0a\u4e24\u4e2a\u5224\u65ad\u5faa\u73af\u5230\u4e24\u4e2a\u6307\u9488\u7684\u5b57\u7b26\u90fd\u662f\u7a7a\u683c

\u7ed3\u675f\uff01

#include"stdio.h"
void main()
{
int i;
char str[100];
printf("请输入一个字符串:");
gets(str);
if(str[0]>=97&&str[0]<=122)
str[0]=str[0]-32;
for(i=1;str[i]!='\0';i++)
{if(str[i-1]==' '&&str[i]>=97&&str[i]<=122)
str[i]=str[i]-32;
}
puts(str);
}

 

希望我的回答会对您有所帮助!



#include<stdio.h>
#define N 100
void main()
{
    char a[N]={"what are you talking about?"};
    int i;
    for(i=0;i<N;i++)
        if(i>0&&a[i-1]==' ')a[i]-=32;
        else if(i==0)a[i]-=32;
    printf("%s",a);
}
//已测试,输出结果为What Are You Talking About?
//因为不知道具体句子是怎么样的,我就按字母都是小写来处理了


扩展阅读:c语言编译器手机版app ... c#从入门到精通pdf下载 ... c#是什么 ... c#入门经典第9版中文版 ... c语言编译器在线编译 ... c#入门 ... c# 绘图 ... c语言新手入门代码 ... c#入门教程下载 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网