ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ###(1)分类 ``` #include<stdio.h> #include<malloc.h> int main(void){ int n,m,i=0,j=0; char *str; char *myInt; char *myChar; scanf("%d",&n); str=(char*)malloc(sizeof(str)*n); myInt=(char*)malloc(sizeof(myInt)*n); myChar=(char*)malloc(sizeof(myChar)*n); scanf("%s",str); for(m=0;m<n;m++){ if(str[m]>='0'&&str[m]<='9'){ myInt[i]=str[m]; i++; } else if(str[m]>='a' && str[m]<='z' || str[m]>='A' && str[m]<='Z'){ myChar[j]=str[m]; j++; } } for(m=0;m<=i;m++){ printf("%c",myInt[m]); } printf("\n"); for(m=0;m<=j;m++){ printf("%c",myChar[m]); } printf("\n"); return 0; } ``` ### (2)找出矩阵中的字符 ``` #include <stdio.h> #include <string.h> int main(void) { int number,n=0,i=0; int x=0; int y=0; int flag=0; scanf("%d",&number); char a[100][10]; while(n<=number) { gets(a[n]); n++; } n=1; while(n<=number) { x=n-1; for(i=0;(size_t)i<strlen(a[n]);i++) { if(a[n][i] == ' ') { y++; if(flag == 1) { flag=0; printf("\n"); } } if(flag == 1) { printf("%c",a[n][i]); } if((a[n][i]<'0' || a[n][i] > '9') && a[n][i]!=' ' && flag==0) { flag = 1; printf("%d %d %c",x,y,a[n][i]); } } y=0; n++; } return 0; } ``` ### (3)矩阵翻转 ``` #include <stdio.h> int main(void) { int m; int i,j; scanf("%d",&m); int myNumber[m][m]; for(i=0;i<m;i++) { for(j=0;j<m;j++) { scanf("%d",&myNumber[i][j]); } } for(i=0;i<m;i++) { for(j=0;j<m;j++) { printf("%d ",myNumber[j][i]); } printf("\n"); } } ``` ### (4)求和 ``` #include <stdio.h> int main() { int num = 0; int sum = 0; char ch; while((ch = getchar()) != '\n') { if(ch >= '0' && ch <= '9') num = 10 * num + ch - '0'; if(ch == '.') { sum += num; num = 0; } } printf("%d\n",sum + num); return 0; } ```