C语言 输入一个长度不超过10的字符串,将小写字母转换为大写,其他不变

作者&投稿:屠谭 (若有异议请与网页底部的电邮联系)
C语言 输入一个长度不超过10的字符串,将小写字母转换为大写,其他不变。~

#include "stdafx.h"
#include "stdio.h"

int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}

char a[10];
void main()
{char temp;
printf("输入一个长度不超过10的字符串(不含空格),按回车结束:
");
scanf("%s",a);
for(int i=0;i<10;i++)
{if(a[i]>=97&&a[i]<=122)
a[i]=a[i]-32;
}
printf("将小写字母转为大写:
");
printf("%s",a);
scanf("%c",&temp);
scanf("%c",&temp);
}

#include "stdio.h"
int main()
{
char str[100]={0};
int i;
printf("请输入一个字符串(10个字符):");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]>='a' && str[i]<='z')
str[i]+='A'-'a';
else if(str[i]>='A' && str[i]<='Z')
str[i]+='a'-'A';

}
printf("变换后输出:%s
",str);

}

#include<stdio.h>
void main()
{
char a[10];
int i;
gets(a);
for(i=0;i<10;i++)
{
if(a[i]!='\0')
{
if(a[i]>=97&&a[i]<=122)
a[i]=a[i]-32;
}
else break;
}
puts(a);
}
测试望采纳



黄山市15199855238: C语言 输入一个长度不超过10的字符串 -
夔俘排石: 展开全部1.#include void main() {char str; gets(str); }/*你只要不按回车你想输多少就输入多少*/2.#include void main() {char c[20]; int i=0; while(1) {scanf("%c",c[i]); i++; if(i==10) break; } } 还有很多方法.

黄山市15199855238: C语言 输入一个长度不超过10的字符串,然后求出输入的字符的长度. 求简单易懂的 -
夔俘排石: #include#include//strlen()函数的头文件 int main(void) { char a[11]; int length=0; printf("please enter words (less than 10 word):\n"); gets(a);//输入字符串 puts(a);//输出字符串 length=strlen(a);//利用这个函数可以求出字符串中的字符个数 printf("字符串长度:length=%d\n",length); return 0; }

黄山市15199855238: C语言 输入一个长度不超过10个字符的字符串,将其排正 -
夔俘排石: #include main() { char *s,c; int i,j; printf("请输入一个字符串,串长不超过10\n"); scanf("%s",s); for(i=0;i for(j=i+1;j if(s[i]>s[j]) { c=s[i]; s[i]=s[j]; s[j]=c; } printf("%s",s); getch(); }

黄山市15199855238: C语言 输入一个长度不超过10的字符串,将它反序输出 -
夔俘排石: # include int main(void) { char * string,* p_str,str[100]; int i = 0; printf("Please enter a string: "); string = str; gets(string); i = strlen(string); for(p_str = string + i;;p_str >= string;p_str--) { printf("%c",*p_str); } putchar('\n'); return 0; }

黄山市15199855238: C语言 输入一个长度不超过10的字符串,将小写字母转换为大写,其他不变 -
夔俘排石: 思路:因为小写字母与其对应的大写字母的ascii码值相差32,则可以定义一个函数,直接遍历输入的字符串,判断该字符是否是小写字母,如果是则自减32即可. 参考代码: #includevoid change(char str[]) { int i; for(i=0;str[i]!='\0';i++) if(str[i]>='a'&&str[i]<='z') str[i]-=32; } int main() { char a[100]; gets(a); change(a); puts(a); return 0; } /* asdfasdf234asdf asdfasdf234asdf */

黄山市15199855238: C语言 输入一个长度不超过10个字符的字符串,将其反序输出.要求两种方法 -
夔俘排石: 第一种:#include <stdio.h>#include <string.h> int main() { char str1[] = "abcd"; char str2[10] = {0}; int i, j=0, len = strlen(str1); for (i=len-1;i>=0;i--) { str2[j] = str1[i]; j++; } for (i=0;i<len;i++) str1[i] = str2[i]; printf("%s\n", str1); return 0; }第二种:#...

黄山市15199855238: C语言 输入一个长度不超过10个字符的字符串,将其排正以及反序输出 -
夔俘排石: 这个问题很简单,每个字符都有对应的ASCII值,你只要对比排序一下再输出显示就可以啦.如:这个是我的排序函数,你只要把排序的缓冲区即数组赋给uint AD_Buff[],就 排序了,,输出用printf()输出就可以.***函数名称:qSort()***//***功...

黄山市15199855238: c 语言:从键盘输入一个长度小于10的数字字符串,将之轮换为相应的整数.例如:如果输入的字符串为“ - 12345”,则将之转换为整数 - 12345.(提示:从字串中从头取出数字字符后,将之转换为相应
夔俘排石: gets(s); int i; int n = 0, f; s[0] == '-' ? i = 1, f = -1 : i = 0, f = 1; for (; s[i]; ++i) { n = n * 10 + f * (s[i] - '0'); }

黄山市15199855238: 从键盘输入一个长度不超过10个且以英文字母为首可以含其他字符的字符串,找出英文字符中的最大最小字符 -
夔俘排石: #include<stdio.h>#include<ctype.h>#include<stdlib.h> int main() { char c,min = 'z',max = 'A'; scanf("%c",&c); while(c != '\n') { if(isalpha(c)) { if(c < min) min = c; if(c > max) max = c; } scanf("%c",&c); } printf("最小的字符是%c\n",min); printf("最大的字符是%c\n",max);system("pause"); return 0; }

黄山市15199855238: c语言编程题;从键盘输入N本图书的书名(书名长度不超过10个汉字)和单价,按单价从高到低顺序排序后输出图书 -
夔俘排石: #include <stdio.h>#include <stdlib.h>#define max_N 10000/*定义书的结构体 *name,书的名字 *price,书的单价 */ struct Book { char name[21]; double price; } book[max_N];//定义快速排序的比较函数 int cmp(const void *a, const void *b) { return ...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网