11智能在线
新记
这个程序怎么写:从键盘输入一个字符串,将其中的小写字母改为大写字母,其他字符不变,并输出这个字符串
这个程序怎么写:从键盘输入一个字符串,将其中的小写字母改为大写字母,其他字符不变,并输出这个字符串,分析运行结果,用字符数组处理。
举报该文章
相关建议 2015-05-29
#include<stdio.h>
void main()
{
int i=0;
char a[100],c;
printf("请输入
字符串
的内容:\t");
do{
scanf("%c",&a[i]);
c=a[i];
i++;
}while(c!='\n');
a[i]='\0';
i=0;
printf("输入字符串的内容为:\t");
while(a[i]!='\0')
{
printf("%c",a[i]);
i++;
}
printf("转换后字符串的内容为:\t");
i=0;
while(a[i]!='\0')
{
c=a[i];
if(c>='a' && c<='z')
a[i]-=32;
else if(c>='A' && c<='Z')
a[i]+=32;
printf("%c",a[i]);
i++;
}
}
追问
题目一开始没有给数组长度是100啊
温馨提示:内容为网友见解,仅供参考
当前网址:
https://11.t2y.org/zz/fvmf74m48m8sf4ms7v7.html
其他看法
第1个回答 2015-06-12
#include <stdio.h>
void change(char s[])
{
int i;
for(i=1;i<=20;i++)
{
if(s[i]>='a'&&s[i]<='z')
s[i]=s[i]-32;
}
}
main()
{
char str[100]="";
scanf("%s",str);
clrscr();
change(str);
printf("%s\n",str);
}
相似回答
大家正在搜
相关问题
C语言编写一个程序:从键盘输入一个字符串,将其中的小写字母全...
从键盘任意输入两个字符串,将所有的大写字母改为小写字母,且小...
输入一个字符串,将其中的大写字母转换为小写字母,其他字符不变...
输入一个字符串,将其中的大写字母改为小写字母,小写字母改为大...
C语言编程,从键盘输入一字符串,将其中的小写字母全部转换成大...
编写一程序实现:从键盘输入一个字符串,将其中的大写字母变成小...
C语言程序题 从键盘输入不多于100个字符长度的字符串,将其...
c++前程 题目是从键盘上输入一个字符串,将其中的小写字母改...