c语言中,如何输入任意一串英文字母,然后按字母相反顺序输出这一串字母? 用C语言,输入三个字母,按字母表顺序输出这三个字母。
c\u8bed\u8a00\u7a0b\u5e8f\u8bbe\u8ba1\uff0c\u8f93\u5165\u4efb\u610f\u4e00\u4e32\u82f1\u6587\u5b57\u6bcd\uff0c\u7136\u540e\u6309\u5b57\u6bcd\u76f8\u53cd\u987a\u5e8f\u8f93\u51fa\u8fd9\u4e00\u4e32\u5b57\u6bcd\u3002#include
#include
void main(void)
{
char ch[100];/*\u5047\u8bbe\u5b57\u7b26\u4e32\u6700\u957f100\u4e2a\u5b57\u7b26*/
printf("\u8bf7\u8f93\u5165\u4e00\u4e2a10\u4e2a\u4e0d\u540c\u82f1\u6587\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\n");
scanf("%s", ch);
int len = strlen(ch);/*\u6c42\u5b57\u7b26\u4e32\u957f\u5ea6*/
for (int i=0; i<len-1; i++)/*\u5192\u6ce1\u6cd5\u6392\u5e8f*/
for (int j=0; j<len-i-1; j++)
if (ch[j]<ch[j+1])
{
char temp=ch[j];
ch[j]=ch[j+1];
ch[j+1]=temp;
}
printf("\u6392\u5e8f\u540e\u7684\u5b57\u7b26\u4e32\u4e3a%s\n", ch);
}
#incldueint main(){char a,b,c,t;scanf("%c%c%c",&a,&b,&c);//\u6ce8\u610f\u8f93\u5165\u6ca1\u6709\u7a7a\u683c\u7684\uff0c\u76f4\u63a5\u5c31\u8fd93\u4e2a\u5b57\u6bcdif (a>b) {t=a;a=b;b=t;}if (a>c) {t=a;a=c;c=t;}if (b>c) {t=c;c=b;b=t;}printf("%c %c %c\n",a,b,c);return 0;}
#include <string.h>#include <stdio.h>
int main(void)
{
char ch[100];/*假设字符串最长100个字符*/
printf("请输入字符串\n");
gets(ch);//可以实现输入空格
int len= strlen(ch);/*求字符串长度*/
for (int i=len;i>=0;i--)
printf("%c", ch[i]);
printf("\n");
}
绛旓細鍐欑殑scanf灏辨彁鍑轰簡瑕佹眰鐨杈撳叆鏄滄暟a鈥 鈥滈楀彿鈥 鈥滄暟b鈥濓紝浣犳棦鐒舵病鏈夌粰鍑閫楀彿锛閭e氨涓鐩存病鏈夌粰b璧嬪硷紝涔熸病鏈夌粰b涓涓垵濮嬪寲鐨勫硷紝閭d箞寰楀嚭鐨勭粨鏋滃氨鏄竴涓殢鏈烘暟銆備互python涓轰緥锛!/usr/bin/env python -*- coding: utf-8 -*- a = input("杈撳叆a锛")b = input("杈撳叆b锛")if a > b...
绛旓細include<iostream> include<string> using namespace std;int main(){ char str[50];int n=0;char *p;p=str;cout<<"璇杈撳叆瀛楃涓:"<<endl;cin>>str;for(int i=0;*p!='\0';p++){ if(('a'<=*p && *p<='z') || ('A'<=*p && *p<='Z')){ n++;cout<<*p<<" ";} el...
绛旓細include<stdio.h> include<stdlib.h> int main(){ char a[80];int i,len,j;printf("杈撳叆鑻辨枃鍗曡瘝浠ヤ竴涓┖鏍煎垎寮");gets(a);len=strlen(a);for (i = 0; i < len; i++){ if (a[i] ==' ')j++;} printf("鏈%d涓崟璇嶏紒",j);} 绁濅綘鎰夊揩锛
绛旓細while (*p != '\0') {char ch = *p;if (ch > 'A' && ch <= 'Z' ||ch >= 'a' && ch <= 'z') {if (!isWord) {if (ch >= 'a' && ch <= 'z')ch -= 32;printf("%c", ch);isWord = true;}}else {isWord = false;}p++;}printf("\n");system("...
绛旓細include<stdio.h> include<string.h> int main(){ char a[11];gets(a);for(int i=0;i<strlen(a);i++)if(a[i]>='a'&&a[i]<='z')a[i]-=32;puts(a);return 0;}
绛旓細浣犵敤scanf璇诲彇杈撳叆锛鑷劧鍙兘璇诲彇涓涓崟璇嶃傜敤gets璇诲彇杈撳叆锛岃兘澶熻鍒版崲琛岀涓烘锛屽苟涓旀妸鎹㈣绗︿涪寮冦
绛旓細cin>>ch;if(ch=='a') cout<<'b';杈撳叆杈撳嚭褰㈠紡鎹竴涓嬩笉灏卞緱浜
绛旓細C璇█绋嬪簭濡備笅锛歩nclude<stdio.h> int main(){ char a[100];char b[24];int s[100] = { 0 };//鐢ㄤ簬瀛樺偍瀛楃鐨勪釜鏁 gets(a);//杈撳叆瀛楃 //寮濮嬫瘮杈 for (int x = 0; x < 24; x++){ int c = 0;//璁板綍姣忎釜瀛楃涓暟 b[x] = x + 97;//涓轰簡璁゜[0]鏄痑锛宐[1]鏄痓渚濇...
绛旓細,'u','v','w','x','y','z'};printf(" 璇杈撳叆涓涓瓧绗︼細");zf1=getchar();if(isupper(zf1)){ zf2=zf1+32;for(i=0;i<26;i++)if(zf2==zf[i])printf(" 瀛楃 %c 鍦鑻辨枃瀛楁瘝涓殑浣嶇疆鏄細绗 %d 涓猏n",zf1,i+1);} else for(i=0;i<26;i++)if(zf1==zf[i]...
绛旓細include<stdio.h> int main(){ int i;for(i=0;i<26;i++)printf("%c ",i+'A')锛沠or(i=0;i<26;i++)printf("%c ",i+'a');return 0;}