07 2020 档案

摘要:题目:编写一个函数,输入n为偶数时,调用函数求1/2+1/4+...+1/n,当输入n为奇数时,调用函数1/1+1/3+...+1/n(利用指针函数)。 程序分析:无。 实例: 1 #include<stdio.h> 2 #include<stdlib.h> 3 double evenumber(i 阅读全文
posted @ 2020-07-14 12:05 C语言自学网 阅读(308) 评论(0) 推荐(0)
摘要:题目:输入一个整数,并将其反转后输出。 程序分析:无。 实例 - 使用 strlen() 1 #include <stdio.h> 2 int main() 3 { 4 int n, reversedNumber = 0, remainder; 5 6 printf("输入一个整数: "); 7 s 阅读全文
posted @ 2020-07-14 12:03 C语言自学网 阅读(206) 评论(0) 推荐(0)
摘要:题目:连接两个链表。 程序分析:无。 实例: 1 #include <stdlib.h> 2 #include <stdio.h> 3 struct list 4 { 5 int data; 6 struct list *next; 7 }; 8 typedef struct list node; 阅读全文
posted @ 2020-07-14 11:50 C语言自学网 阅读(256) 评论(0) 推荐(0)
摘要:题目:反向输出一个链表。 程序分析:无。 实例: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<malloc.h> 4 typedef struct LNode{ 5 int data; 6 struct LNode *next; 7 }LN 阅读全文
posted @ 2020-07-14 11:48 C语言自学网 阅读(184) 评论(0) 推荐(0)
摘要:题目:创建一个链表。 程序分析:无。 实例: 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<malloc.h> 4 typedef struct LNode{ 5 int data; 6 struct LNode *next; 7 }LNod 阅读全文
posted @ 2020-07-14 11:47 C语言自学网 阅读(219) 评论(0) 推荐(0)
摘要:题目:编写input()和output()函数输入,输出5个学生的数据记录。 程序分析:无。 程序源代码: 1 #include<stdio.h> 2 #include<stdlib.h> 3 typedef struct{ 4 char name[20]; 5 char sex[5]; 6 int 阅读全文
posted @ 2020-07-11 16:55 C语言自学网 阅读(371) 评论(0) 推荐(0)
摘要:头文件添加方法:工程 属性 配置属性 c/c++ 常规 附加包含目录(Additional Include Directories):加上头文件存放目录。注意:(1)路径必须指向头文件所在的子文件夹,而不能直到父文件夹就结束(2)每个路径不需要加上双引号,输入了之后,vs会自动加上双引号,如果自己加 阅读全文
posted @ 2020-07-11 15:49 C语言自学网 阅读(1673) 评论(0) 推荐(2)
摘要:题目:写一个函数,求一个字符串的长度,在main函数中输入字符串,并输出其长度。 程序分析:无。 实例: 1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() 4 { 5 int len; 6 char str[20]; 7 printf(" 阅读全文
posted @ 2020-07-11 15:26 C语言自学网 阅读(294) 评论(0) 推荐(0)
摘要:题目:有n个人围成一圈,顺序排号。从第一个人开始报数(从1到3报数),凡报到3的人退出圈子,问最后留下的是原来第几号的那位。 程序分析:无。 实例: 1 #include <stdio.h> 2 void main() 3 { 4 int num[50],n,*p,j,loop,i,m,k; 5 p 阅读全文
posted @ 2020-07-11 15:19 C语言自学网 阅读(251) 评论(0) 推荐(0)
摘要:题目:有 n个整数,使其前面各数顺序向后移 m 个位置,最后m个数变成最前面的 m 个数。 程序分析:无。 实例: 1 #include <stdio.h> 2 #include <stdlib.h> 3 int main() 4 { 5 int arr[20]; 6 int i,n,offset; 阅读全文
posted @ 2020-07-11 15:00 C语言自学网 阅读(358) 评论(0) 推荐(0)
摘要:题目:输入数组,最大的与第一个元素交换,最小的与最后一个元素交换,输出数组。 程序分析:谭浩强的书中答案有问题。 实例: 1 #include<stdio.h> 2 #include<stdlib.h> 3 4 void fun(int *s,int n) 5 { 6 int i; 7 int ma 阅读全文
posted @ 2020-07-11 14:42 C语言自学网 阅读(310) 评论(0) 推荐(0)
摘要:题目:输入3个数a,b,c,按大小顺序输出。 程序分析:利用指针方法。 实例: 1 # include<stdio.h> 2 3 void swap(int *, int *); 4 int main(void) 5 { 6 int a, b, c; 7 int *p1, *p2, *p3; 8 p 阅读全文
posted @ 2020-07-11 14:41 C语言自学网 阅读(235) 评论(0) 推荐(0)
摘要:题目:一个最优美的图案(在TC中实现)。 程序分析:无。 程序源代码: 1 #include "graphics.h" 2 #include "math.h" 3 #include "dos.h" 4 #include "conio.h" 5 #include "stdlib.h" 6 #inclu 阅读全文
posted @ 2020-07-11 14:39 C语言自学网 阅读(238) 评论(0) 推荐(0)
摘要:题目:利用ellipse and rectangle 画图(在TC中实现)。 程序分析:无。 程序源代码: 1 #include "stdio.h" 2 #include "graphics.h" 3 #include "conio.h" 4 main() 5 { 6 int driver=VGA, 阅读全文
posted @ 2020-07-11 14:38 C语言自学网 阅读(279) 评论(0) 推荐(0)
摘要:题目:画椭圆ellipse(在TC中实现)。 程序分析:无。 程序源代码: 1 #include "stdio.h" 2 #include "graphics.h" 3 #include "conio.h" 4 int main() 5 { 6 int x=360,y=160,driver=VGA, 阅读全文
posted @ 2020-07-04 17:23 C语言自学网 阅读(252) 评论(0) 推荐(0)
摘要:题目:学习putpixel画点,(在TC中实现)。 程序分析:无。 程序源代码: 1 #include "stdio.h" 2 #include "graphics.h" 3 int main() 4 { 5 int i,j,driver=VGA,mode=VGAHI; 6 initgraph(&d 阅读全文
posted @ 2020-07-04 17:20 C语言自学网 阅读(205) 评论(0) 推荐(0)
摘要:题目:打印出杨辉三角形(要求打印出10行)。 程序分析: 结构如下所示: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 实例: 1 #include <stdio.h> 2 3 int main() 4 { 5 int i,j; 6 int a[10][10]; 7 printf("\ 阅读全文
posted @ 2020-07-04 17:10 C语言自学网 阅读(426) 评论(0) 推荐(0)
摘要:题目:画图,综合例子2。(在TC中实现)。 程序分析:无。 程序源代码: 1 #include "graphics.h" 2 #define LEFT 0 3 #define TOP 0 4 #define RIGHT 639 5 #define BOTTOM 479 6 #define LINES 阅读全文
posted @ 2020-07-04 16:52 C语言自学网 阅读(226) 评论(0) 推荐(0)
摘要:题目:画图,综合例子。(在TC中实现)。 程序分析:无。 程序源代码: 1 # define PAI 3.1415926 2 # define B 0.809 3 # include "graphics.h" 4 #include "math.h" 5 int main() 6 { 7 int i, 阅读全文
posted @ 2020-07-04 16:47 C语言自学网 阅读(248) 评论(0) 推荐(0)
摘要:题目:学用rectangle画方形。(在TC中实现)。 程序分析:无。 程序源代码: 1 #include "graphics.h" 2 int main() 3 { 4 int x0,y0,y1,x1,driver,mode,i; 5 driver=VGA;mode=VGAHI; 6 initgr 阅读全文
posted @ 2020-07-04 16:38 C语言自学网 阅读(221) 评论(0) 推荐(1)