摘要: 画表格在图形环境中很容易做出漂亮的表格。但在控制台环境中就比较困难了。有的时候可以用一些符号大略地模拟:(word文档中可能不整齐,拷贝到记事本中看)+-------+------+|abc |xyz=tt|+-------+------+|hellomm|t2 |+-------+------+本题目要求设计一个程序,把用户输入的内容用这种“准表格”的方式展现出来。具体的要求是:用户输入的第一行是一个整数,表示接下来有多少行信息。接下来的每行由若干单元组成。单元间用逗号分开。程序输出:用表格方式重新展现的输入内容。例如:用户输入:3cat,dog,good-luck1,2,5do not u 阅读全文
posted @ 2013-05-02 18:01 Please Call me 小强 阅读(359) 评论(0) 推荐(0) 编辑
摘要: 已知平面上若干个点的坐标。需要求出在所有的组合中,4个点间平均距离的最小值(四舍五入,保留2位小数)。比如有4个点:a,b,c,d, 则平均距离是指:ab, ac, ad, bc, bd, cd 这6个距离的平均值。每个点的坐标表示为:横坐标,纵坐标坐标的取值范围是:1~1000例如,如果程序输入:10,1020,2080,5010,2020,10则程序应该输出:11.38 1 #include<stdio.h> 2 #include<malloc.h> 3 #include<math.h> 4 typedef struct Point 5 { 6 doub 阅读全文
posted @ 2013-05-02 11:45 Please Call me 小强 阅读(616) 评论(0) 推荐(0) 编辑
摘要: 在编程中常会碰到,在某一个集合中,选集合中的几个数据进行计算。决定写个类似伪代码的代码,方便日后编程。int index=0;保存结果的集合;void fun(集合,集合长度,要选取的长度){ if(集合长度 < 要选取的长度) return ; if(要选取的长度<=0) {自己想要实现的功能模块} for(int i=0;i<集合长度;i++) { 保存结果的集合[index++]=集合[i]; fun(集合+i+1,集合长度-i-1,要选取的长度-1); index--; }} 阅读全文
posted @ 2013-05-02 11:24 Please Call me 小强 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<conio.h> 3 int fun(int m,int n) 4 { 5 if(m==n)return 1; 6 if(n==1)return m; 7 return fun(m-1,n)+fun(m-1,n-1); 8 } 9 int main()10 {11 printf("%d\n",fun(7,3));12 getch();13 return 0;14 } 阅读全文
posted @ 2013-05-02 11:04 Please Call me 小强 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<conio.h> 3 int result[100]; 4 5 void split(int n, int k, int c) 6 { 7 if (k == 0) return; 8 if (n == k) 9 {10 result[c]=k;11 for (int i = 0; i <=c; i++)12 printf("%d ",result[i]);13 printf("\n"); 14 if (k == 1)... 阅读全文
posted @ 2013-05-02 11:01 Please Call me 小强 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<conio.h> 3 char pStr[20]="abcd"; 4 void swap(char *a,char *b) 5 { 6 char temp = *a; 7 *a = *b; 8 *b = temp; 9 }10 void comp(char *pBegin)11 {12 if(!*pBegin)puts(pStr);13 char *p=pBegin;14 for(;*p;p++)15 {16 swap(p,pBegin);17 ... 阅读全文
posted @ 2013-05-02 10:58 Please Call me 小强 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 1 #include<stdio.h> 2 #include<string.h> 3 4 char s[50]; 5 int index=0; 6 void reSort(char *pArray, int remainNum, int printLen) 7 { 8 if (remainNum < printLen)return; 9 if (printLen <= 0)10 {11 for(int i=0;i<index;i++)12 putchar(s[i]);13 putchar('\n');14 ... 阅读全文
posted @ 2013-05-02 10:55 Please Call me 小强 阅读(199) 评论(0) 推荐(0) 编辑