C语言程序:题目:从键盘输入一个字符串,按照字符顺序从小到大进行排序,并要求删除重复的字符。答案如下 C语言。从键盘接收一个字符串,然后按照字符顺序从小到大进行排...
C\u8bed\u8a00\u7a0b\u5e8f\uff1a\u9898\u76ee\uff1a\u4ece\u952e\u76d8\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u6309\u7167\u5b57\u7b26\u987a\u5e8f\u4ece\u5c0f\u5230\u5927\u8fdb\u884c\u6392\u5e8f\uff0c\u5e76\u8981\u6c42\u5220\u9664\u91cd\u590d\u7684\u5b57\u7b26\u3002\u7b54\u6848\u5982\u4e0b#include
#include"string.h"
int
main(void)
{
char
str1[500]={0},str2[256]={0};//\u5b9a\u4e49\u4e8c\u4e2a\u6570\u7ec4\uff0c\u5e76\u8d4b\u521d\u503c\u4e3a0
int
i;
gets(str1);//\u8bfb\u53d6\u4e00\u4e2a\u5b57\u7b26\u4e32
for(i=0;str1[i];i++)
{
str2[str1[i]]=1;//str1\u4e2d\u6bcf\u4e2a\u5b57\u7b26\u7684assic\u7801\u4f5c\u4e3astr2\u7684\u4e0b\u6807\u503c\uff0c\u5e76\u628a\u5bf9\u5e94\u4f4d\u7f6e\u586b\u5145\u4e3a1\uff0c\u540c\u4e00\u4e2a\u5b57\u7b26\u7684assci\u503c\u76f8\u540c\uff0c\u6240\u4ee5\u8fd9\u6837\u5c31\u53bb\u6389\u4e86\u91cd\u590d\u5b57\u7b26
}
for(i=0;i!=256;i++)
if(str2[i]==1)//\u5224\u65ad\u6570\u7ec4\u4e2d\u88abstr1\u586b\u5145\u7684\u4f4d\u7f6e\uff0c\u586b\u5145\u7684\u662f\u975e0\u503c\uff0c\u6ca1\u586b\u5145\u7684\u662f0\u503c
printf("%c",i);//\u8f93\u51fastr2\u7684\u4e0b\u6807\u503c\uff0c\u5bf9\u5e94str1\u4e2d\u7684\u5b57\u7b26\u503c
putchar('\n');
return
0;
}
1 A 2 B 3 D
\u4e0a\u673a\u8bd5\u8fc7\u7684
#include"string.h"
int main(void)
{
char str1[500]={0},str2[256]={0};//定义二个数组,并赋初值为0
int i;
gets(str1);//读取一个字符串
for(i=0;str1[i];i++)
{
str2[str1[i]]=1;//str1中每个字符的assic码作为str2的下标值,并把对应位置填充为1,同一个字符的assci值相同,所以这样就去掉了重复字符
}
for(i=0;i!=256;i++)
if(str2[i]==1)//判断数组中被str1填充的位置,填充的是非0值,没填充的是0值
printf("%c",i);//输出str2的下标值,对应str1中的字符值
putchar('\n');
return 0;
}
绛旓細include <stdio.h> int main(){ int n;scanf("%d", &n);if(n > 0) printf("姝f暟");else if(n < 0) printf("璐熸暟");else{printf("闆");} return 0;}
绛旓細include<stdio.h>int main(){char a;scanf("%c",&a);printf("%c",a+1);return 0;}
绛旓細printf("璇杈撳叆涓涓鏁存暟!\n"); scanf("%lu",&num); for(i=1;i<=num;i++){ if(num%i==0) cnt++; } printf("姝ゆ暟鍏辨湁%lu涓笉鍚屾鏁存暟鍥犲瓙銆俓n",cnt); return 0;} 鏈洖绛旂敱鎻愰棶鑰呮帹鑽 涓炬姤| 绛旀绾犻敊 | 璇勮 1 0 涓婂笣鏉ヨ嚜鍦扮悆 閲囩撼鐜:66% 鎿呴暱: C/C++ 姹囩紪璇█ 鍏朵粬缂栫▼璇█ 鐧惧害...
绛旓細銆C璇█杈撳叆灏忓啓瀛楁瘝锛岃緭鍑烘樉绀轰负澶у啓瀛楁瘝涓昏鐢ㄥ埌瀛楃銆戜緥瀛愬涓嬶細鐩存帴缂栬瘧锛绋嬪簭杈撳嚭缁撴灉涓杈撳叆浠绘剰灏忓啓瀛楁瘝锛屾寜鍥炶溅锛屽緱鍒扮粨鏋滃涓嬪浘鎵绀猴細
绛旓細涓昏閮ㄥ垎濡備笅锛歝har c;cin>>c;if(c>='0'||c<='9')cout<<"digital character";if(c>='a"||c<='z')cout<<"alphabetic character";else cout<<"other character";澶ц嚧灏辫繖鏍峰惂
绛旓細鏈汉涔熸槸瀛C璇█鐨勶紝浠ヤ笅鐨绋嬪簭鏄寜鐓т綘鐨勮姹傜紪鍐欑殑锛#include <stdio.h> //姹傝緭鍏ユ暟鍚勪綅鏁扮殑绔嬫柟鍜 void main(){ int x,sum=0,j;printf("璇杈撳叆涓涓鏁存暟锛");scanf("%d",&x); //杈撳叆涓涓暟 while(x!=0) //鍒ゆ柇X鏄惁涓洪浂 { j=x%10; //鍙栦釜浣嶆暟瀛 sum+=j*j*...
绛旓細鍙互鍙傝冧笅闈㈢殑浠g爜锛歩nclude <stdio.h> void main(){ char ch;scanf("%c",&ch);if(ch>='A'&&ch<='Z'){ ch=ch+32;printf("%c\n\n",ch);}else{ printf("%c\n\n",ch);} }
绛旓細void main(){ char input[1000];int i=0,out[26]={0},j;char outstring[26]= {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};cout<<"Please input capital password:";fge...
绛旓細flag;//杈撳叆涓涓插瓧绗rintf("Input a string:");gets(s);//杈撳叆鎯宠鏌ユ壘鐨勫瓧绗rintf("Input another string:");gets(d);//璋冪敤鍑芥暟锛岃緭鍑虹粨鏋渇lag=SearchString(s,d);if(flag==-1)printf("Not found!\n");elseprintf("Searching results:%d\n",flag);system("pause");...
绛旓細include <stdio.h>int main(void){ int n,t,f; printf("Input n(int 9<n<100001)...\nn="); if(scanf("%d",&n)!=1 || n<10 || n>100000){ printf("Input error, exit...\n"); return 0; } for(t=n,f=1;t>9;f*=10,t/=10); printf("T...