企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ###(1)分类 ``` #include <stdio.h> int main(void) { int m,x; int i=0,j=0; char c; scanf("%d",&m); int myInt[m]; char myChar[m]; for(x=0;x<=m;x++) { c = getchar(); if('0'< c && c <'9') { myInt[i] = c-'0'; i++; } else { myChar[j] = c; j++; } } for(x = 0;x<i;x++) { printf("%d",myInt[x]); } printf("\n"); for(x = 1;x<j;x++) { printf("%c",myChar[x]); } } ``` ### (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[number+1][10]; while(n<=number) { gets(a[n]); n++; } n=1; while(n<=number) { x=n-1; for(i=0;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++; } } ``` ### (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(void) { int strLength = 15; scanf("%d",&strLength); char str[strLength+1]; int myNumber[strLength]; scanf("%s",str); int x = 0; int i = 0; int j = 0; int sum = 0; for(i=0;i<strLength;) { myNumber[j] = 0; while(i<strLength && str[i] != '.') { myNumber[j] = 10 * myNumber[j] + str[i++] - '0'; } ++i; ++j; } for(x=0;x<j;x++) { sum += myNumber[x]; } printf("%d",sum); return 0; } ``` ``` #include<stdio.h> #include<malloc.h> int main() { int i=0,n,m=0; int sum=0; char* str; scanf("%d",&n); str=(char *)malloc(sizeof(char)*n); scanf("%s",str); while(i<n) { if(str[i]>='0'&&str[i]<='9') { m = m*10+str[i]-'0'; } if(str[i]=='.' || i==n-1) { sum=sum+m; m=0; } i++; } printf("%d\n",sum); return 0; } ```