🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ###(1)分类 ``` #include<stdio.h> #include<string.h> #include<malloc.h> int main(){ int i,m=0,n=0,x=0; char* p; int* q; char* str; scanf("%d\n",&i); str = (char *)malloc(sizeof(char)*(i)); p = (char *)malloc(sizeof(char)*(i)); q = (int *)malloc(sizeof(int)*(i)); scanf("%s",str); for(x=0;x<=i;x++) { if('0'<= str[x] && str[x] <='9'){ q[m++] = str[x]; } if(str[x]<='z'&&str[x]>='a'||str[x]<='Z'&&str[x]>='A'){ p[n++] =str[x]; } } for(x=0;x<=m;x++){ printf("%d",q[x]); } printf("\n"); for(x=0;x<=n;x++){ printf("%s",p[x]); } return 0; } ``` ### (3)矩阵翻转 ```` #include<stdio.h> int main(){ int m=0,n=0,i; scanf("%d",&i); int C[100][100]; for(m=0;m<i;m++){ for(n=0;n<i;n++){ scanf("%d ",&C[m][n]); } } printf("\n"); for(m=0;m<i;m++){ for(n=0;n<i;n++){ printf("%d ",C[n][m]); } printf("\n"); } return 0; } ``` ### (4)求和 ``` #include<stdio.h> #include<malloc.h> int main(){ int m,i=0,z=0,sum=0; char *str; scanf("%d",&m); str = (char *)malloc(sizeof(char)*(m)); scanf("%s",str); while(i<m) { if(str[i]>='0'&&str[i]<='9') { z=z*10+str[i]-'0'; } if(str[i]=='.'||i==m-1) { sum=sum+z; z=0; } i++; } printf("%d\n",sum); return 0; } ```