随笔分类 -  c语言

摘要: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 阅读全文
posted @ 2019-12-23 15:01 jason2018 阅读(147) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-22 17:04 jason2018 阅读(375) 评论(0) 推荐(0)
摘要: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) 阅读全文
posted @ 2019-12-20 16:26 jason2018 阅读(644) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-20 15:01 jason2018 阅读(1212) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-20 12:40 jason2018 阅读(1104) 评论(0) 推荐(0)
摘要: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] = 阅读全文
posted @ 2019-12-20 12:18 jason2018 阅读(790) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-20 11:59 jason2018 阅读(2781) 评论(0) 推荐(0)
摘要: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 = 阅读全文
posted @ 2019-12-20 10:47 jason2018 阅读(340) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-19 14:07 jason2018 阅读(452) 评论(0) 推荐(0)
摘要: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字符串 阅读全文
posted @ 2019-12-19 10:51 jason2018 阅读(1107) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-18 11:22 jason2018 阅读(178) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-17 16:06 jason2018 阅读(134) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-17 14:48 jason2018 阅读(163) 评论(0) 推荐(0)
摘要: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]) 阅读全文
posted @ 2019-12-17 09:21 jason2018 阅读(189) 评论(0) 推荐(0)
摘要:利用指针返回多个函数值 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 阅读全文
posted @ 2019-12-15 16:44 jason2018 阅读(164) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-13 09:29 jason2018 阅读(273) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-12 14:48 jason2018 阅读(1513) 评论(0) 推荐(0)
摘要: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; //初始化,第一 阅读全文
posted @ 2019-12-12 14:40 jason2018 阅读(553) 评论(0) 推荐(0)
摘要: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 < 阅读全文
posted @ 2019-12-12 13:36 jason2018 阅读(636) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-12 13:23 jason2018 阅读(189) 评论(0) 推荐(0)