MICROSOFT的C编译器就是不一样,BORLAND不行喽

      计算机与编程 2007-4-28 15:01:00

发觉论C的编译器的IDE还是MICROSOFT的比较好,以前练习用的BORLAND的真的不知道怎么熬过来的。

下面这个例子是针对IF,FOR,WHILE三种逻辑控制的综合运用,很简单,供初学者练习。代码的意义为输入任意两个数,程序会把两个数之间的整数从大到小,再从小到大分别打印到屏幕输出出来。

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

main()

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

 if (from>to)
 {
 int mid;
 mid=from;
 from=to;
 to=mid;
 }

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

 int i;
 for (i=from;i<=to;++i)
 {
 cout<<i<<", ";
 }

 while (i>=from)
 {
 cout<<i<<", ";
 --i;
 }
cout<<endl;
return 0;
}

标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}