c语言中如何在一个字符串里搜索出其中的字母和数字啊?谢谢 如何用c语言分离字符串中的字母和数字并分别输出?
C\u8bed\u8a00\u95ee\u9898\uff1a\u5982\u4f55\u4ece\u4e00\u4e2a\u7531\u5b57\u6bcd\u548c\u6570\u5b57\u7ec4\u6210\u7684\u5b57\u7b26\u4e32\u4e2d\u63d0\u53d6\u51fa\u76f8\u5e94\u7684\u5b57\u6bcd\uff1f#include int main(int argc, char const *argv[]){ char line[1024] = "\0"; // = 'a' and line[i] = 'A' and line[i] <= 'Z') ) printf("%c",line[i]); } printf("\n"); return 0;}\u8fd0\u884c\uff1a
Cat808her_+in_+e87Catherine
\u628a\u5b57\u7b26\u4e32\u5b58\u653e\u5230\u6570\u7ec4\u91cc\u9762,\u4e00\u4e2a\u4e00\u4e2a\u6bd4\u5bf9\uff08\u5faa\u73af\uff09\u540e\u8f93\u51fa
\u5224\u65ad\u6570\u5b57\uff1a
for (i=0;i<n;i++){
if ((p[i]>='0') && (p[i]<='9'))
printf();
\u5224\u65ad\u5b57\u6bcd\uff1a
for (i=0;i<n;i++){
if ((p[i]>='a') && (p[i]<='Z'))
printf();
\u6269\u5c55\u8d44\u6599\uff1a
\u901a\u5e38\u4ee5\u4e32\u7684\u6574\u4f53\u4f5c\u4e3a\u64cd\u4f5c\u5bf9\u8c61\uff0c\u5982\uff1a\u5728\u4e32\u4e2d\u67e5\u627e\u67d0\u4e2a\u5b50\u4e32\u3001\u6c42\u53d6\u4e00\u4e2a\u5b50\u4e32\u3001\u5728\u4e32\u7684\u67d0\u4e2a\u4f4d\u7f6e\u4e0a\u63d2\u5165\u4e00\u4e2a\u5b50\u4e32\u4ee5\u53ca\u5220\u9664\u4e00\u4e2a\u5b50\u4e32\u7b49\u3002\u4e24\u4e2a\u5b57\u7b26\u4e32\u76f8\u7b49\u7684\u5145\u8981\u6761\u4ef6\u662f\uff1a\u957f\u5ea6\u76f8\u7b49\uff0c\u5e76\u4e14\u5404\u4e2a\u5bf9\u5e94\u4f4d\u7f6e\u4e0a\u7684\u5b57\u7b26\u90fd\u76f8\u7b49\u3002\u8bbep\u3001q\u662f\u4e24\u4e2a\u4e32\uff0c\u6c42q\u5728p\u4e2d\u9996\u6b21\u51fa\u73b0\u7684\u4f4d\u7f6e\u7684\u8fd0\u7b97\u53eb\u505a\u6a21\u5f0f\u5339\u914d\u3002\u4e32\u7684\u4e24\u79cd\u6700\u57fa\u672c\u7684\u5b58\u50a8\u65b9\u5f0f\u662f\u987a\u5e8f\u5b58\u50a8\u65b9\u5f0f\u548c\u94fe\u63a5\u5b58\u50a8\u65b9\u5f0f\u3002
\u53c2\u8003\u8d44\u6599\u6765\u6e90\uff1a\u767e\u5ea6\u767e\u79d1-\u5b57\u7b26\u4e32
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int main(){
char str[1000]; //字符串
memset(str,1000,0);
scanf("%s",str);
char ch;
int pos1(0),pos2(0);
char s1[500],s2[500];
memset(s1,500,0);
memset(s2,500,0);
for(int i=0;i<strlen(str);i++){
ch=str[i];
if(ch<='9'&& ch>='0'){ //统计数字个数
s1[pos1++]=ch;
}
if( (ch<='z'&&ch>='a') ||(ch>='A'&&ch<='Z') ){
s2[pos2++]=ch;
}
}
printf("%s\n",s1);
printf("%s\n",s2);
system("pause");
return 0;
}
绛旓細include <stdio.h>#define N 7int change(char a[],char b,char c) { int i = 0,count = 0; while(a[i] != '\0') { if(a[i] == b) a[i] = c; count++; i++; } return count;}int main() {char a[N],b,c;int i;printf("璇疯緭鍏6涓瓧绗锛歕n");for(i = 0...
绛旓細} return isFind; }void main(){ int i; char x, y, a[N]; gets(a); scanf("%c,%c", &x, &y); //%c鍜%c涔嬪墠鏈夐楀彿,闅斿紑 if( Exchange(a, x, y) ){ puts(a); } else printf("娌℃湁琚浛鎹n");...
绛旓細scanf("%s",a);printf("\n璇疯緭鍏ュ瓧绗︿覆B(鍦20涓瓧绗浠ュ唴):");scanf("%s",b);for(i=0,j=0;a[i]!='\0';i++){ if(a[i]==b[j]){ j++;} if(b[j]=='\0'){ ++t;j=0;} } printf("\n瀛楃涓 %s 鍦ㄥ瓧绗︿覆 %s 閲岄潰鍏卞嚭鐜 %d 娆n",b,a,t);} c-free娴嬭瘯閫氳繃 ...
绛旓細婧愪唬鐮:include<stdio.h> include<string.h>//璋冪敤string.h涓殑strstr鍑芥暟 void main(){ char ch1[255]="abcde";char ch2[100]="cd";char* ch;//鐢ㄤ簬鎺ュ彈杩斿洖鍊 if((ch=strstr(ch1,ch2))==NULL){//璇存槑娌℃湁瑕佹壘鐨勫瓧绗︿覆 printf("-1\n");}else{//璇存槑鎵惧埌浜嗛偅涓瓧绗︿覆 printf("%d...
绛旓細鎯冲疄鐜颁綘鐨勫姛鑳戒綘鍙互璁剧疆涓涓鏍囧織浣 鍒濆鍊 tag=0 if锛坰[i]==c锛墈 tag=1;printf();} 鍦╢or寰幆涔嬪 if(tag==0)printf锛"鎵句笉鍒");ps锛氬鏋滃彧鎵剧涓娆″嚭鐜帮紝鍦╥f锛坰[i]==c锛変腑鍔犱釜break for 寰幆鏈濂藉姞涓婂ぇ鎷彿 鐪嬩竴涓媠trchr 鍑芥暟 鍜宻trrchr鍑芥暟鍚 搴旇鏈変綘鎯宠鐨 include<strin...
绛旓細int main(){ char str[100]; // 瀹氫箟瀛楃鏁扮粍锛屽瓨鍌ㄨ緭鍏鐨勫瓧绗︿覆 char ch; // 瀹氫箟瀛楃鍙橀噺锛屽瓨鍌ㄨ緭鍏ョ殑鎸囧畾瀛楃 printf("璇疯緭鍏ヤ竴琛屽瓧绗︼細");fgets(str, sizeof(str), stdin); // 璇诲叆涓琛屽瓧绗 printf("璇疯緭鍏ヤ竴涓寚瀹氬瓧绗︼細");ch = getchar(); // 璇诲叆涓涓瓧绗 int i;for (i = ...
绛旓細include<stdio.h>int main(){ char str[100]; char s[100],num[100]; int index=0,index1=0,index2=0; gets(str);//杈撳叆瀛楃涓 while(str[index]!='\0') { if((str[index]>='a' && str[index]<='z')||(str[index]>='A' && str[index]<='Z'))...
绛旓細include <stdio.h> include <string.h> include <malloc.h> int search(char * strSource, char * strFind){ int find_len=strlen(strFind);int i=0;int flag=0;while( *(strSource+i) != '\0' ){ if(*(strSource+i) == *strFind){ if(strncmp(strSource+i,strFind,find_len) ...
绛旓細C涓殑瀛楃涓灏辨槸涓涓瓧绗鏁扮粍銆傚锛歝har s[10]="wo shi SB";char c;鍙栨渶宸﹁竟鐨勫瓧绗,灏辨槸c=s[0];
绛旓細scanf("%c",&character);printf("Input a string : ");scanf("%s",st);for(i=0;st[i]!='\0';i++){ if(character==st[i]){ d=i;s=1;break;} } if(1==s)printf("%d \n",d);if(s != 1)puts("NOT FOUND\n");return 0;} 鍦ㄥ垽鏂槸鍚︽湁鐨勬椂鍊欒鍍忔垜璇彞閲岄潰閭f牱濂戒簺...