ZKX's LAB

从键盘输入一字符串 从键盘输入一个字符串,分别输出其完全大写和完全小写的形式

2021-04-09知识3

从键盘输入一个字符串 #includevoid main(){char str[256];int i,k,n;gets(str);键盘回车结束scanf(\"%s\",str)键盘空2113格结束i=0;k=0;n=1;while(str[i]){if(str[k]>;str[i]){k=i;n=1;}else if(str[k]=str[i])n+;i+;}printf(\"字符5261值最小字符为4102%c,第1次出现位置%d,出1653现次数%d\\n\",str[k],k,n);}

从键盘输入一个字符串, #includeint find(char*s,char c){int i;for(i=0;s[i]。e799bee5baa6e4b893e5b19e31333335313839=0;i+)if(s[i]=c)return i;return-1;}void delete(char*s,int idx){int i;for(i=idx;s[i]。0;i+)s[i]=s[i+1];}void main(){char s[100];char c;int idx;printf(\"Input a string:\");gets(s);printf(\"input a charactor:\");scanf(\"%c\",&c);idx=find(s,c);if(idx。1){printf(\"index=d\\n\",idx);delete(s,idx);printf(\"after delete:%s\\n\",s);}else{printf(\"not find%c.\\n\",c);}}

从键盘怎么读入一个字符串,c语言中用gets #includeint main(void){char str[100];printf(\"请输入5261一个字4102符串1653:\\n\");gets(str);printf(\"你输入了:%s\",str);}

随机阅读

qrcode
访问手机版