12 2019 档案
摘要:1 #include <stdio.h> 2 3 struct time 4 { 5 int hour; 6 int minute; 7 int second; 8 }; 9 int main(void) 10 { 11 int n, temp; 12 struct time t1; 13 14 s
阅读全文
摘要:1 #include <stdio.h> 2 int main(void) 3 { 4 printf("%zd\n", sizeof(5L)); //long int型整数 5 printf("%zd\n", sizeof(5LL)); //long long int型整数 6 7 printf("
阅读全文
摘要:1 #include <stdio.h> 2 int main(void) 3 { 4 printf("sizeof(short int) = %zd\n", sizeof(short int)); 5 printf("sizeof(int) = %zd\n", sizeof(int)); 6 pr
阅读全文
摘要:1 #include <stdio.h> 2 int leap(int year); //闰年返回1,否则返回0 3 int yeardays(int year, int month, int day); //返回一年中的第几天 4 int days(int year); //返回一年的总天数 5
阅读全文
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main(void) 5 { 6 int n; 7 double *p; 8 scanf("%d", &n); 9 10 p = (double *)calloc(n, sizeof(double)
阅读全文
摘要:1 #include <stdio.h> 2 #include <string.h> 3 4 int main(void) 5 { 6 char str[5][80]; //二维数组保存5个字符串 7 int i, j; 8 9 for (i = 0; i < 5; i++) 10 { 11 sca
阅读全文
摘要:1 void StringCount(char* s) 2 { 3 int len = 0; 4 char* p = s; 5 int cap_letter = 0; 6 int sma_letter = 0; 7 int space = 0; 8 int digit = 0; 9 int othe
阅读全文
摘要:1 void delchar(char *str, char c) 2 { 3 int i, j; 4 char a[MAXN]; 5 6 j = 0; 7 for (i = 0; str[i] != '\0'; i++) 8 { 9 if (str[i] != c) 10 { 11 a[j] =
阅读全文
摘要:1 void strmcpy(char *t, int m, char *s) 2 { 3 int len = 0; //计算字符串t的长度 4 char *p = t; 5 int i; 6 while (*p != '\0') 7 { 8 len++; 9 p++; 10 } 11 12 if
阅读全文
摘要:1 void CountOff(int n, int m, int out[]) 2 { 3 4 int person[n + 1]; 5 int i; 6 int count; 7 8 /* 9 给编号1到n的人打上标签 10 =0在圈子中 11 =1退出圈子 12 */ 13 for (i =
阅读全文
摘要:1 int ArrayShift(int a[], int n, int m) 2 { 3 int at[MAXN]; 4 5 m = m % n; 6 for (int i = 0; i < m; i++) 7 { 8 at[i] = a[n - m + i]; 9 } 10 for (int i
阅读全文
摘要:1 void Shift(char s[]) 2 { 3 char st1[MAXS]; 4 char st2[MAXS]; 5 strcpy(st1, s); 6 st1[3] = '\0'; //st1字符串中只有s字符串的前3个字符 7 strcpy(st2, s + 3); //st2字符串
阅读全文
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main(void) 5 { 6 int number; 7 int *a; 8 int i; 9 printf("请输入数量:"); 10 scanf("%d", &number); 11 //i
阅读全文
摘要:1 #include <stdio.h> 2 3 int main(void) 4 { 5 char a[] = "hello"; //字符串以字符串数组的形式保存,末尾加上'\n' 6 printf("%d\n", sizeof(a)); 7 8 for (int i = 0; i < sizeo
阅读全文
摘要:1 #include <stdio.h> 2 void minmax(int *a, int len, int *min, int *max); 3 int main(void) 4 { 5 int a[] = { 6 1, 7 2, 8 3, 9 4, 10 5, 11 6, 12 7, 13 8
阅读全文
摘要:1 #include <stdio.h> 2 3 int main(void) 4 { 5 6 int a[10]; 7 8 printf("%p\n",&a); 9 printf("%p\n",a); 10 printf("%p\n",&a[0]); 11 printf("%p\n",&a[1])
阅读全文
摘要:每次启动powershell后输入:chcp 65001
阅读全文
摘要:利用指针返回多个函数值 1 #include <stdio.h> 2 void month_day(int year, int yearday, int *pmonth, int *pday); 3 4 int main(void) 5 { 6 int day, month, year, yeard
阅读全文
摘要:z 1 #include <stdio.h> 2 3 double f(double *p, double x); 4 int main(void) 5 { 6 7 double an[4]; 8 double a, b; 9 for (int i = 3; i >= 0; i--) 10 { 11
阅读全文
摘要:1 #include <stdio.h> 2 3 int main(void) 4 { 5 int num; 6 int n, sum; 7 8 n = 0; 9 sum = 0; 10 scanf("%d", &num); 11 12 do 13 { 14 sum = sum + num % 10
阅读全文
摘要:1 #include <stdio.h> 2 3 int main(void) 4 { 5 int a, b; 6 int t; 7 int month; 8 int amount; 9 10 scanf("%d", &amount); 11 12 a = 0; 13 b = 1; //初始化,第一
阅读全文
摘要:1 #include <stdio.h> 2 3 int main(void) 4 { 5 int m, n; 6 int gcd, lcm; 7 scanf("%d %d", &m, &n); 8 int t1 = m; 9 int t2 = n; 10 11 int t; 12 if (m <
阅读全文
摘要:1 #include <stdio.h> 2 3 int main(void) 4 { 5 int num; 6 int sum = 0; 7 while (1) 8 { 9 scanf("%d", &num); 10 if (num <= 0) 11 { 12 break; 13 } 14 els
阅读全文
摘要:1 #include <stdio.h> 2 3 int main(void) 4 { 5 int magic_number, n; 6 int guess_number; 7 int count = 0; 8 9 scanf("%d %d", &magic_number, &n); 10 11 d
阅读全文
摘要:1 #include <stdio.h> 2 #include <math.h> 3 int main(void) 4 { 5 double x, y; 6 7 scanf("%lf", &x); 8 9 /*浮点数比较大小*/ 10 if (fabs(x - 15.0) > 1e-6 && x >
阅读全文
摘要:1 #include <stdio.h> 2 3 int main(void) 4 { 5 int a, b, c; 6 char other; 7 8 scanf("%d %d %d", &a, &b, &c); 9 10 if (a == b) 11 { 12 other = 'C'; 13 }
阅读全文
摘要:程序只验证了样例。 1 #include<stdio.h> 2 3 int main(void) 4 { 5 int a[101] = { 0 }; 6 int b[101] = { 0 }; 7 8 int m, n; 9 10 for (int i = 0; i < 2; i++) 11 { 1
阅读全文
摘要:思路:每次找出数组中最大的数,放到后面。 1 #include<stdio.h> 2 3 int max_index(int a[], int len); 4 int main(void) 5 { 6 int a[] = { 2,45,6,12,87,34,90,24,23,11,65 }; 7 i
阅读全文
摘要:1 #include<stdio.h> 2 3 int search(int key, int a[], int len); 4 int main(void) 5 { 6 int a[] = { 1,3,6,7,8,9,10,11,13 }; 7 int k = 11; //需要找的数 8 int
阅读全文
摘要:查找美分对应的英文单词 1、用两个数组 1 #include<stdio.h> 2 3 int amount[] = { 1,5,10,25,50 }; 4 char* name[] = { "penny","mickel","dimme","quarter","half-dollar" }; 5
阅读全文
摘要:1 /* 2 构造素数表 3 思路: 4 欲构造n以内的素数表 5 1、令x为2 6 2、将2x、3x、4x直至ax<n的数标记为非素数 7 3、令y为下一个没有被标记为非素数的数,重复第二步; 8 4、直到所有的数都已经尝试完毕 9 10 伪代码: 11 欲构造n以内(不含)的素数表 12 1、开
阅读全文
摘要:浙大慕课程序 1 /*判断是否能被已知的且<x的素数整除*/ 2 #include<stdio.h> 3 4 int main(void) 5 { 6 int prime[10] = { 2 }; //初始化素数表 7 int count = 1; 8 int i = 3; //从3开始,判断素数
阅读全文
摘要:1 #include<stdio.h> 2 3 int is_hex(char ch); //判断是否是十六进制字符,是返回1 4 int hex_to_dec(char ch); //十六进制字符转换位十进制数 5 int main(void) 6 { 7 char a[80], b[80]; 8
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 char a[80], b[80]; 6 int i; 7 8 i = 0; //有效字符的个数 9 10 while (i < 80) 11 { 12 a[i] = getchar(); 13 if (a[i
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 char a[80]; 6 int i; 7 8 i = 0; 9 while ((a[i] = getchar()) != '\n') 10 { 11 i++; 12 } 13 a[i] = '\0'; 14
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int n; 6 int a[6][6]; 7 int row_max[6]; //每 一行的最大数 8 int col_min[6]; //每一列的最大数 9 10 scanf_s("%d", &n); 11
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 printf("%d %o %x\n", 10, 10, 10); //输出八进制是%o,不是0 6 printf("%d %o %X\n", 10, 10, 10); //%X,大写的X,输出的十六进制数值也
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int m, n; 6 int a[6][6]; 7 8 scanf_s("%d %d", &m, &n); 9 10 for (int i = 0; i < m; i++) 11 { 12 for (int
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int t; 6 scanf_s("%d", &t); 7 8 for (int i = 0; i < t; i++) 9 { 10 int n; 11 int a[10][10]; 12 13 scanf_s
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int n; 6 int number[1000]; 7 int digit[10] = {0}; //记录每个数字出现的次数 8 int temp; 9 10 scanf_s("%d", &n); 11 fo
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int n; 6 int number[10]; 7 8 scanf_s("%d", &n); 9 10 for (int i = 0; i < n; i++) 11 { 12 scanf_s("%d", &n
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 char str[80]; 6 char chs[80]; 7 int i; 8 for (i = 0; i < 80; i++) 9 { 10 str[i] = getchar(); 11 if (str[i
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int i; 6 char str[80]; 7 char ch, temp; 8 9 ch = getchar(); //需要查找的字符 10 temp = getchar(); //第一行回车 11 12
阅读全文
摘要:1 #include<stdio.h> 2 3 int day_of_year(int year, int month, int day); 4 int main(void) 5 { 6 int year, month, day; 7 8 scanf_s("%d/%d/%d", &year, &mo
阅读全文
摘要:用了两个矩阵来完成,可能会有更好的方法。 1 #include<stdio.h> 2 3 int main(void) 4 { 5 int a[6][6], b[6][6]; 6 int m, n; 7 int temp; 8 9 scanf_s("%d %d", &m, &n); 10 11 fo
阅读全文
摘要:1 #include<stdio.h> 2 3 int main(void) 4 { 5 int a[10][10]; 6 int n; 7 8 scanf_s("%d", &n); 9 10 for (int i = 0; i < n; i++) 11 { 12 for (int j = 0; j
阅读全文
摘要:1 void StringCount(char s[]) 2 { 3 int letter, blank, digit, other; 4 5 letter = 0; 6 blank = 0; 7 digit = 0; 8 other = 0; 9 10 int i = 0; 11 while (s
阅读全文
摘要:写了两个函数。 1 int even( int n ) 2 { 3 int ret = 1; 4 5 if (n < 0) 6 { 7 n = -n; 8 } 9 if (n % 2 == 1) 10 { 11 ret = 0; 12 } 13 14 return ret; 15 } 16 int
阅读全文
摘要:程序只验证了样例 1 #include<stdio.h> 2 3 int q, r; //全局变量 4 int div(int a, int b); 5 int main(void) 6 { 7 int a, b; 8 int count = 0; 9 10 scanf("%d/%d", &a, &
阅读全文
摘要:1 #include<stdio.h> 2 4 int array_in(int x, int a[], int n); 5 6 int main(void) 7 { 8 int m, n, k; //三个数组的大小 9 10 /*第一个数组,数组长度是变量,C99支持,但vs不支持*/ 11 sc
阅读全文