上一页 1 ··· 315 316 317 318 319 320 321 322 323 ··· 407 下一页
摘要: c语言中使用putchar显示字符串 1、 #include <stdio.h> int put(char x[]) { int i = 0; while(x[i]) putchar(x[i++]); } int main(void) { char str[128]; printf("str: ") 阅读全文
posted @ 2021-05-26 12:23 小鲨鱼2018 阅读(433) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> int search(char x[], int c) { int i = 0, j = 0; while(1) { if(x[i] == c) { j++; } if(x[i] == '\0') break; i++; } return j == 0 ? 阅读全文
posted @ 2021-05-26 11:38 小鲨鱼2018 阅读(66) 评论(0) 推荐(0)
摘要: 1、线性查找法 #include <stdio.h> #define FAILED -1 int len(char x[]) { int len = 0; while(x[len]) len++; return len; } int search(char x[], char key) { int 阅读全文
posted @ 2021-05-25 23:02 小鲨鱼2018 阅读(60) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> void null_string(char x[]) { x[0] = '\0'; } int main(void) { char str[128]; printf("str: "); scanf("%s", str); printf("begin: %s 阅读全文
posted @ 2021-05-25 22:10 小鲨鱼2018 阅读(58) 评论(0) 推荐(0)
摘要: c语言中输出字符串的长度。 1、 #include <stdio.h> int str_len(const char x[]) { int len = 0; while(x[len]) len++; return len; } int main(void) { char str[100]; prin 阅读全文
posted @ 2021-05-25 21:56 小鲨鱼2018 阅读(1320) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> #define NUMBER 10 int main(void) { int i; char s[NUMBER][128]; for(i = 0; i < NUMBER; i++) { printf("s[%d] = ", i); scanf("%s", 阅读全文
posted @ 2021-05-25 21:10 小鲨鱼2018 阅读(81) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> int main(void) { char s[] = "ABC"; printf("begin: %s\n", s); int i; for(i = 0; i < 4; i++) { s[i] = '\0'; } printf("end: %s\n", 阅读全文
posted @ 2021-05-25 18:26 小鲨鱼2018 阅读(120) 评论(0) 推荐(0)
摘要: 字符串字面量的中间也可以有null字符,不过应注意区分。字符串字面量“ABC”是字符串,而字符串字面量“AB\0CD”不是字符串。 1、 #include <stdio.h> int main(void) { char str[] = "ABC\0DEF"; printf("result: %s.\ 阅读全文
posted @ 2021-05-25 18:08 小鲨鱼2018 阅读(142) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> int gcd(int x, int y) { int max, min, tmp; max = x > y ? x : y; min = x > y ? y : x; tmp = x % y; if(tmp != 0) { gcd(min, tmp); 阅读全文
posted @ 2021-05-25 12:58 小鲨鱼2018 阅读(96) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> int fac(int x) { if(x > 0) return x * fac(x - 1); else return 1; } int main(void) { int n, r; puts("please input two integers.") 阅读全文
posted @ 2021-05-25 11:40 小鲨鱼2018 阅读(85) 评论(0) 推荐(0)
上一页 1 ··· 315 316 317 318 319 320 321 322 323 ··· 407 下一页