- 博客(7)
- 收藏
- 关注
原创 C语言:数组循环右移
#include <stdio.h>#define MAXN 10void ArrayShift(int a[], int n, int m);int main(){ int a[MAXN], n, m; int i; scanf("%d %d", &n, &m); for (i = 0; i < n; i++) scanf("%d", &a[i]); ArrayShift(a, n, m); for...
2022-01-27 10:58:59 740
原创 C语言:使用函数输出一个整数的逆序数
#include <stdio.h>int reverse(int number);int main(){ int n; scanf("%d", &n); printf("%d\n", reverse(n)); return 0;}int reverse(int number) { int sign = 1; int num = 0; if (number < 0) { sign = -1;...
2022-01-27 10:27:41 1941
原创 C语言:使用函数验证哥德巴赫猜想
#include <stdio.h>#include <math.h>int prime(int p);void Goldbach(int n);int main(){ int m, n, i, cnt; scanf("%d %d", &m, &n); if (prime(m) != 0) printf("%d is a prime number\n", m); if (m < 6) m = 6; if (...
2022-01-26 12:15:42 2550 1
原创 C语言:使用函数输出指定范围内的Fibonacci数
#include <stdio.h>int fib(int n);void PrintFN(int m, int n);int main(){ int m, n, t; scanf("%d %d %d", &m, &n, &t); printf("fib(%d) = %d\n", t, fib(t)); PrintFN(m, n); return 0;}int fib(int n) { int fib =...
2022-01-24 10:46:10 748
原创 C语言:使用函数输出指定范围内的完数
//使用函数输出指定范围内的完数#include <stdio.h>int factorsum(int number);void PrintPN(int m, int n);int main(){ int m, n; scanf("%d %d", &m, &n); if (factorsum(m) == m) printf("%d is a perfect number\n", m); if (factorsum(n) == n) ...
2022-01-21 12:14:44 2169
原创 C语言:使用函数求特殊a串数列和
#include <stdio.h>#include <math.h>int fn(int a, int n);int SumA(int a, int n);int main(){ int a, n; scanf("%d %d", &a, &n); printf("fn(%d, %d) = %d\n", a, n, fn(a, n)); printf("s = %d\n", SumA(a, n)); retur...
2022-01-20 10:32:56 753
原创 C语言: 分类统计字符个数
#include <stdio.h>#include <string.h>#define MAXS 15void StringCount(char s[]);void ReadString(char s[]);int main() { char s[MAXS]; gets_s(s, MAXS); //scanf不能存储空格 ReadString(s); StringCount(s);}void StringCount(char s[])...
2022-01-20 09:43:59 1541
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人