Open sq4250 opened 1 year ago
#include <stdio.h> int mysplit(char *p); int main() { char str[200]; gets(str); printf("%d words\n", mysplit(str)); return 0; } int mysplit(char *p) { int sum = 0; for (int i = 0; *(p + i) != '\0'; i++) { if (*(p + i) != '\x20') printf("%c", *(p + i)); if ((*(p + i + 1) == '\x20' || *(p + i + 1) == '\0') && *(p + i) != '\x20') { sum++; printf("\n"); } } return sum; }
输入x,y,z求最大值:
#include <stdio.h> void max(int **ppm, char **ppc); int main() { int a[3]; char c[3] = {'x', 'y', 'z'}; for (int i = 0; i < 3; i++) { printf("输入%c的值:", *(c + i)); scanf("%d", a + i); } int *pm = a; char *pc = c; max(&pm, &pc); printf("最大值为: %c = %d\n", *pc, *pm); return 0; } void max(int **ppm, char **ppc) { int max = **ppm; for (int i = 1; i < 3; i++) if (max < *(*ppm + i)) max = *(*ppm + i); for (int i = 0; i < 3; i++) if (max == *(*ppm + i)) { *ppm = *ppm + i; *ppc = *ppc + i; break; } }
输入x,y,z求最大值: