一个类似于金字塔的图形

摘要: 输入26以内的数字 输出一个字母组成的金字塔 本来想用c++写 到一半发现不能控制字符输出 然后又用的printf 显得有点乱 还有就是把第一个i=100,改成i=101输出的程序有问题 不知道该怎么解决 现放出代码 1 #include 2 using namespace std; 3 int main() 4 { 5 int i,j,k,x; 6 char f[100]; 7 cin>>x; 8 for (i=1;i0;j--)13 cout0;k--)17 printf("%c",f[k]);18 ... 阅读全文
posted @ 2013-11-28 20:20 一颗向上的草莓 阅读(349) 评论(0) 推荐(0) 编辑

Fibonacci数

摘要: 描述无穷数列1,1,2,3,5,8,13,21,34,55...称为Fibonacci数列,它可以递归地定义为F(n)=1 ...........(n=1或n=2)F(n)=F(n-1)+F(n-2).....(n>2)现要你来求第n个斐波纳奇数。(第1个、第二个都为1)输入第一行是一个整数m(m>m;14 while(m--)15 {16 cin>>n;17 cout<<fib(n)<<endl;18 }19 return 0;20 }View Code 阅读全文
posted @ 2013-11-24 22:34 一颗向上的草莓 阅读(91) 评论(0) 推荐(0) 编辑

快来秒杀我

摘要: 题目描述根据前几次竞赛的情况,这次为了给新手们一点信心,特提供这道秒杀题来让大家杀。ASCII码大家应该都学过了,现在给你一个很简单的任务,输入数字,表示ASCII码,输出对应的文本内容。输入格式输入的第一行是一个整数T(1 2 int main() 3 { 4 int T,a[100],i; 5 scanf("%d",&T); 6 while(T) 7 { 8 for(i=0;i<T;i++) 9 {10 scanf("%d",&a[i]);11 printf("%c",a[i]);12 ... 阅读全文
posted @ 2013-11-24 22:11 一颗向上的草莓 阅读(300) 评论(0) 推荐(0) 编辑

奇偶数分离

摘要: 奇偶数分离时间限制:3000 ms | 内存限制:65535 KB难度:1描述有一个整型偶数n(2 2 using namespace std; 3 int main() 4 { 5 int i,j,n,t; 6 cin>>i; 7 while(i--) 8 { 9 cin>>n;10 for(j=1;j<n;j=j+2)11 cout<<j<<" ";12 cout<<endl;13 for(t=2;t<=n;t=t+2)14 cout<<t... 阅读全文
posted @ 2013-11-16 22:23 一颗向上的草莓 阅读(216) 评论(0) 推荐(0) 编辑

Background

摘要: Asimplemathematicalformulaforeiswherenisallowedtogotoinfinity.Thiscanactuallyyieldveryaccurateapproximationsofeusingrelativelysmallvaluesofn.OutputOutputtheapproximationsofegeneratedbytheaboveformulaforthevaluesofnfrom0to9.Thebeginningofyouroutputshouldappearsimilartothatshownbelow.ExampleOutputne-- 阅读全文
posted @ 2013-09-25 18:32 一颗向上的草莓 阅读(164) 评论(0) 推荐(0) 编辑

Financial Management

摘要: Larrygraduatedthisyearandfinallyhasajob.He'smakingalotofmoney,butsomehowneverseemstohaveenough.Larryhasdecidedthatheneedstograbholdofhisfinancialportfolioandsolvehisfinancingproblems.Thefirststepistofigureoutwhat'sbeengoingonwithhismoney.Larryhashisbankaccountstatementsandwantstoseehowmuchmo 阅读全文
posted @ 2013-09-24 16:20 一颗向上的草莓 阅读(225) 评论(2) 推荐(0) 编辑

HangOver

摘要: 1 #include 2 using namespace std; 3 int main() 4 { 5 float c; 6 while((cin>>c)&&c!=0) 7 { 8 float sum=0; 9 int n=2;10 while(sum<c)11 {12 sum=sum+1.00/n;13 n++;14 }15 cout<<n-2;16 }17 return 0;18 }View Code Howfarcanyoumakeastackofcardsoverhangatable?Ifyouhaveonec... 阅读全文
posted @ 2013-09-24 16:14 一颗向上的草莓 阅读(304) 评论(0) 推荐(0) 编辑

Binary String Matching

摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=5描述Given two strings A and B, whose alphabet consist only ‘0’ and ‘1’. Your task is only to tell how many times does A appear as a substring of B? For example, the text string B is ‘1001110110’ while the pattern string A is ‘11’, you should output 3, 阅读全文
posted @ 2013-09-20 14:51 一颗向上的草莓 阅读(191) 评论(0) 推荐(0) 编辑