随笔分类 -  c语言

上一页 1 2 3 4 5 6 7 ··· 9 下一页
摘要:https://pintia.cn/problem-sets/13/problems/408 1 #include <stdio.h> 2 int main(void) 3 { 4 int lower, upper; 5 int fahr; 6 double celsius; 7 8 scanf(" 阅读全文
posted @ 2020-02-02 21:07 jason2018 阅读(1016) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/13/problems/403 1 #include <stdio.h> 2 int main(void) 3 { 4 int start_time, end_time; 5 int start_minutes, end_minutes; 阅读全文
posted @ 2020-02-02 20:24 jason2018 阅读(578) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/358这个题目和十进制数转换成二进制数类似。 用一个两位数来思考递归的过程,就容易多了。 void printdigits(int n) { if (n < 10) { printf("%d\n", n); } e 阅读全文
posted @ 2020-01-26 15:36 jason2018 阅读(1325) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/357 这个题目对于理解递归很有帮助,递归第一个结束的程序是出口。 1 void dectobin(int n) 2 { 3 if (n <= 1) 4 { 5 printf("%d", n); 6 } 7 els 阅读全文
posted @ 2020-01-26 15:21 jason2018 阅读(169) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/356 1 int f(int n) 2 { 3 int ret; 4 5 if (n == 0) 6 { 7 ret = 0; 8 } 9 else if (n == 1) 10 { 11 ret = 1; 12 阅读全文
posted @ 2020-01-25 21:33 jason2018 阅读(456) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/355 1 int Ack(int m, int n) 2 { 3 int ret; 4 5 if (m == 0) 6 { 7 ret = n + 1; 8 } 9 else if (n == 0 && m > 阅读全文
posted @ 2020-01-25 21:29 jason2018 阅读(572) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/353 1 double calc_pow(double x, int n) 2 { 3 double ret; 4 5 if (n == 0) 6 { 7 ret = 1; 8 } 9 else 10 { 11 阅读全文
posted @ 2020-01-25 20:33 jason2018 阅读(570) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/352 1 double fact(int n) 2 { 3 double product; 4 if (n == 0) 5 { 6 product = 1; 7 } 8 else 9 { 10 product = 阅读全文
posted @ 2020-01-25 20:19 jason2018 阅读(641) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/351 1 int search(int n) 2 { 3 int count = 0; 4 int num_sqrt; //平方根的整数部分 5 int single, ten, hundred; 6 for ( 阅读全文
posted @ 2020-01-25 20:05 jason2018 阅读(690) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/350 1 int sum(int n) 2 { 3 if (n <= 0) 4 { 5 return 0; 6 } 7 else 8 { 9 return n + sum(n - 1); 10 } 11 } 阅读全文
posted @ 2020-01-17 14:28 jason2018 阅读(1602) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/347 1 #include <stdio.h> 2 #include <stdlib.h> 3 struct friend 4 { 5 char name[11]; 6 int birthday; 7 char 阅读全文
posted @ 2020-01-17 14:17 jason2018 阅读(680) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/349 1 int set_grade(struct student *p, int n) 2 { 3 int i, count; 4 5 count = 0; 6 for (i = 0; i < n; i++) 阅读全文
posted @ 2020-01-17 12:29 jason2018 阅读(484) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/348 1 struct complex multiply(struct complex x, struct complex y) 2 { 3 struct complex ret; 4 5 ret.real = 阅读全文
posted @ 2020-01-17 12:17 jason2018 阅读(947) 评论(0) 推荐(0)
摘要:1 /*修改学生成绩,结构指针作为函数参数*/ 2 #include <stdio.h> 3 struct student 4 { 5 int num; 6 char name[10]; 7 int computer, english, math; 8 double average; 9 }; 10 阅读全文
posted @ 2020-01-17 09:11 jason2018 阅读(124) 评论(0) 推荐(0)
摘要:1 #include <stdio.h> 2 int main(void) 3 { 4 int a; 5 char c; 6 7 scanf("%d", &a); 8 c = getchar(); 9 putchar(c); 10 11 return 0; 12 } 输入1,然后回车 整数1读入到变 阅读全文
posted @ 2020-01-17 08:27 jason2018 阅读(89) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/346 这个程序的算法不难,因为没有学透标准输入和输出,特别是gets()函数。如果不用getchar()读取多余的'\n',程序就会运行错误。 1 #include <stdio.h> 2 #include <s 阅读全文
posted @ 2020-01-16 20:45 jason2018 阅读(153) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/345 解决舍入问题。 1 #include <stdio.h> 2 #include <math.h> 3 4 int main(void) 5 { 6 struct p 7 { 8 double x; 9 do 阅读全文
posted @ 2020-01-15 14:34 jason2018 阅读(246) 评论(0) 推荐(0)
摘要:https://pintia.cn/problem-sets/12/problems/342 1 bool palindrome(char *s) 2 { 3 int n, i, k; 4 bool ret; 5 6 n = strlen(s); 7 i = 0; 8 k = n - 1; 9 wh 阅读全文
posted @ 2020-01-14 19:41 jason2018 阅读(144) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-12-26 08:54 jason2018 阅读(358) 评论(0) 推荐(0)
摘要: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(" 阅读全文
posted @ 2019-12-23 15:44 jason2018 阅读(1058) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 ··· 9 下一页