
C语言练习
_刘小洋
Android开发
展开
-
C语言 经典练习 输出当前时间的下一秒
输出当前的时间的下一秒 C 语言实现!#include #include #include enum DateType{ YEAR, MONTH, DAY, HOUR, MINUTE, SEC, MAX,};#define DUMMY 0const char *g_apcCnName[MAX]={"年","月","日原创 2014-07-16 20:50:13 · 4397 阅读 · 0 评论 -
HDU 2105 The Center of Gravity
Problem DescriptionEveryone know the story that how Newton discovered the Universal Gravitation. One day, Newton walked leisurely, suddenly, an apple hit his head. Then Newton discovered the Uni原创 2014-07-22 00:08:53 · 464 阅读 · 0 评论 -
HDU 1257 最少拦截系统
Problem Description某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能超过前一发的高度.某天,雷达捕捉到敌国的导弹来袭.由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹.怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里原创 2014-07-21 22:51:52 · 410 阅读 · 0 评论 -
C语言实现 递归法 数字转换成字符串
#include #include int binary_to_ascii(unsigned int value){ unsigned int quotient; quotient = value/10; if( quotient != 0) binary_to_ascii(quotient); putchar ( value % 1原创 2014-07-16 21:08:28 · 1007 阅读 · 0 评论 -
C语言比较 回车符和零的区别
#include #include #include //本程序比较\n 和 \0 的区别//\n 的 ASCII是13 \0的ASCII是0 空格是(space) 32int main(){ char c; int i=0,j,j1,pos,flag; char a[100],b[100],h[100]; while((c=getchar()))/原创 2014-07-16 21:07:13 · 782 阅读 · 0 评论 -
C语言实现 递归法求最大公约数
#include #include int main(){ int pc(int x,int y); int m,n; scanf("%d %d",&m,&n); printf("%d ",pc(m,n)); return 0;}int pc(int x,int y){ int z; z=x%y; if(z==0)原创 2014-07-16 21:10:01 · 2189 阅读 · 0 评论 -
C语言实现 hanio问题
#include #include int mov(int n,char a ,char b){ printf("number %d from %c to %c ...\n",n,a,b); return 0;}int hanio(int n,char a,char b,char c){ if(n==1) mov(1,a,c); els原创 2014-07-16 21:11:00 · 934 阅读 · 0 评论 -
求一亿以内N的质数!筛选法
求n以内素数。 素数又称质数,它是这样的整数,它除了能表示为它自己和1的乘积以外,不能表示为任何其它两个整数的乘积。 有两种方法:筛选法和开根号法 筛选法:从小到大筛去一个已知素数的所有倍数。依次删除可被2整除,3整除。。。。的数字,剩下的则为素数 。 开根号法:如果一个数(>2),对这个数求平方根,如果这个数能被这个数的平方根到2之原创 2014-07-16 21:01:49 · 1410 阅读 · 0 评论 -
C语言实现 递归 数字转换成字符串
#include #include int binary_to_ascii(unsigned int value){ unsigned int quotient; quotient = value/10; if( quotient != 0) binary_to_ascii(quotient); putchar ( value % 1原创 2014-07-16 21:16:34 · 840 阅读 · 0 评论 -
C语言实现 小球自由落体问题
/* 功能:一个球从100米自由落下,每次落下反弹回原来高度的一半,再落下,求它第10次落地时共经过多少米?第10次反弹是多高? */#include//#define N 2int N;float localheight(int n){ int i,h=1; float height; for(i=n;i>=1;i--) { h=h*2; } heig原创 2014-07-16 21:02:58 · 7502 阅读 · 0 评论 -
C语言实现 N!的质因数分解
前几天在网上看的一个例子 觉得很好 递归非常爽的原创 2014-07-16 20:58:23 · 2190 阅读 · 0 评论 -
C 语言 数字删除
数字删除【问题描述】给定一个r位(r【输入形式】从标准输入读入n+1行,其中第一行是正整数s(s【输出形式】将计算结果写到标准输出上,每50个数字一行,每5个数字之间由一个空格符分隔。【输入样例1】2123321【输出样例1】3321【输入样例2】11234567【输出样例2】23456789北航的一道测试原创 2014-07-22 23:10:06 · 1066 阅读 · 0 评论