How to construct a DiamondOfNumbers
2012-10-06 16:31
120 查看
Like this:
We may use the transform thought to solve this problem
We may use the transform thought to solve this problem
#include <iostream> using namespace std; int main() { int Num; cout << "Enter any number in the range of 1 to 9 : "; cin >> Num; if(Num >= 1 && Num <= 9) { for(int Y=-Num;Y!=Num;Y++) { if(Y!=0) { for(int X=1;X!=(Y<0?-Y:Y+1);X++) printf(" "); for( X=-(Y<0?Num+Y+1:Num-Y);X!=(Y<0?Num+Y+1:Num-Y);X++) if(X!=0) printf("%d",(X<0?-X:X+1)); printf("\n"); } } } else printf("Sorry, limit exceeded. Try again."); return 0; }
相关文章推荐
- CareerCup How to find medium of 1 billion numbers across N distributed machines efficiently?
- 如何给上传控件上色【HOW TO SET CSS FOR THE CONTROL OF FILEUPLOAD】
- How to GET a Cup of Coffee
- How To Change the Partition Column Of A Partitioned Table Using DBMS_Redefinition [ID 846405.1]
- FLEX how to reduce the amount of code to reduce memory consumption
- How.To.Process.Image.Infomation.Of.Rotate.And.Flip.From.Server
- How to properly logout of a Java EE 6 Web Application after logging in
- How to create a batch of VMs with PowerShell
- How to change text of CBA buttons?
- How to handle CRM Error of "View not copied or enhanced with wizard; processing not possible"
- How to Change the language of a site template
- How to: How to disable Java Security Warning "The application requires an earlier version of Java."
- How to choose the number oftopics/partitions in a Kafka cluster?
- How to Get Language of Browser:JS&VBS
- How to find the correct version of JDeveloper to use with eBusiness Suite 11i or Release 12.x
- How to save content/text of a web page by forcing save-as option
- how to calculate receptive field of CNN
- How to run multiple instances of Tomcat in one Windows machine
- On Linux, how to tell how many cores of the machine are active?
- “The execution of scripts is disabled on this system” … How to run your own PowerShell scripts