2007/04/26 | 中午咨询了一个C++友人,同样的问题,算法改进如下
类别(计算机与编程) | 评论(0) | 阅读(13) | 发表于 16:38

/* another programme about the same thing...list nums between 2 nums...*/

#include <iostream.h>
#include <string.h>

main()
{
 cout << "====================" << endl;
 cout << "please input 2 nums:" << endl;
 int from, to;
 cout << endl << "please input the from.value: ";
 cin >> from;
 cout << endl;
 cout << "please input the to.value: ";
    cin >> to;
 cout << endl;
 cout << "====================" << endl;

 if (from > to)
    {
    int MID;
    MID=from;
    from=to;
    to=MID;
    } // 确保from <= to

 int line = 0; // 断行
 for (int i = from; i <= to; ++i)
    {
  cout << i << " ";
  if (++line % 10 == 0) cout << endl; // 十次一断行
 }

 cout << endl;
 cout << "the big one is: "<< to << endl;

 return 0;

//this is a programme about list nums, aman designed.

}

0

评论Comments

日志分类
首页[666]
计算机与编程[133]
EMU[40]
UFOs[24]
房产[127]
音乐[13]
LOG[0]
经济[120]
影视[3]
物理[7]
数学[8]
社会[105]
职场[9]
生物医学[18]
生活[59]