CY_

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

08 2013 档案

摘要:闲来无事,整理了一下C语言printf() 的格式控制语句。PS:详细来源于网络。printf的格式控制的完整格式:% - 0 m.n l或h 格式字符下面对组成格式说明的各项加以说明:①%:表示格式说明的起始符号,不可缺少。②-:有-表示左对齐输出,如省略表示右对齐输出。③0:有0表示指定空位填0,如省略表示指定空位不填。④m.n:m指域宽,即对应的输出项在输出设备上所占的字符数。N指精度。用于说明输出的实型数的小数位数。未指定n时,隐含的精度为n=6位。⑤l或h:l对整型指long型,对实型指double型。h用于将整型的格式字符修正为short型。格式字符格式字符用以指定输出项的数据类型 阅读全文
posted @ 2013-08-28 12:59 CY_ 阅读(399) 评论(0) 推荐(0)

摘要:十进制与八进制的转换(栈和队列)Description对于输入的任意一个非负十进制整数,利用栈打印输出与其等值的八进制数。Input111Output157Sample Input148Sample Output224思想很简单,n除8取余,利用栈先进后出的特点成功实现10进制到8进制的转换代码:#include #includeusing namespace std;int main(){ stack s; int n; while(cin>>n&&n>0) { stack s; while(n>0) { ... 阅读全文
posted @ 2013-08-16 15:47 CY_ 阅读(341) 评论(0) 推荐(0)

摘要:Problem Description有一只经过训练的蜜蜂只能爬向右侧相邻的蜂房,不能反向爬行。请编程计算蜜蜂从蜂房a爬到蜂房b的可能路线数。其中,蜂房的结构如下所示。Input输入数据的第一行是一个整数N,表示测试实例的个数,然后是N 行数据,每行包含两个整数a和b(0b = a—>b-1 +a—>b-2 = a—>b-1-1 + a—>b-1-2 + a—>b-2-1 + b-2-2……最终是到a—>a+1 和a—>a+2然后就是转化成递推了由于a,b取值均在(1,50)之间,所以中间数据可以用一个含有50个元素的数组表示a[50];a[0] = 阅读全文
posted @ 2013-08-15 15:26 CY_ 阅读(191) 评论(0) 推荐(0)

摘要:Problem A: WERTYUDescriptionA common typing error is to place yourhands on the keyboard one row to the right of the correct position. Then ``Q'' is typed as ``W'' and ``J'' is typed as ``K'' and so on. Your task is to decode a message typed inthis manner.InputInput co 阅读全文
posted @ 2013-08-10 11:43 CY_ 阅读(225) 评论(0) 推荐(0)

摘要:#includeusing namespace std;int main(){ int n; while(cin>>n) { if((n+1)%4==3) cout=2).InputInput consists of a sequence of lines, each containing an integer n. (n > no 阅读全文
posted @ 2013-08-03 19:22 CY_ 阅读(141) 评论(0) 推荐(0)

摘要:DescriptionGraphical editors such as Photoshop allow us to alter bit-mapped images in the same way that text editors allow us to modify documents. Images are represented as an M x N array of pixels, where each pixel has a given color. Your task is to write a program which simulates a simple interact 阅读全文
posted @ 2013-08-02 11:37 CY_ 阅读(264) 评论(0) 推荐(0)