|登录 |注册

楼主: goodday
打印 上一主题 下一主题

闲聊

[复制链接]
zechs
2008-9-23 12:22 AM
原帖由 虚空使者 于 2008-9-23 12:08 AM 发表
现在只是在学一些简单的罢了
大概都看得懂吧...#include
using namespace std;

int main()
{
//declare two integers
int a,b;
couta>>b;
cout


input第一个a,input第二个b,然后加起来。。。
有时候我觉得学programming和学数学是一样的。。。

回复 #11 zechs 的帖子

虚空使者
2008-9-23 08:38 AM
我数学并不是很好的说...
下个Term就要学Computing Maths了...
都不懂要怎样死...
goodhermit95
2008-9-23 09:00 PM
我看得懂 em0013

#include<iostream>
using namespace std;

int main()
{
//declare two integers
int a,b; //declare two items
cout<<"Enter two integers\n"; //Display Words
cin>>a>>b; //calculate
cout<<''sum of the two integers = "<<a+b<<\n"; //show answer

return 0; //return
} //end
虚空使者
2008-9-24 04:13 PM
今天又学了一些比较复杂的code...
不过对高手来说还是太简单了吧...
话说头脑不厉害转的话要学写code有点吃力~
  1. #include<iostream>
  2. using namespace std;

  3. int main()
  4. {
  5.     //declare three integers
  6.     int a,b,c;
  7.     cout<<"Enter 3 numbers\n";
  8.     cin>>a>>b>>c;
  9.     cout<<"sum of the three integers = "<<a+b+c<<"\n";
  10.     cout<<"average of the three integers = "<<(a+b+c)/3<<"\n";
  11.     cout<<"product of the three integers = "<<a*b*c<<"\n";

  12.     if(a>b)
  13.     {
  14.         if(a>c)
  15.         {
  16.             cout<<a<<"is the largest\n";
  17.         }
  18.         else
  19.         {
  20.             cout<<c<<"is the largest\n";
  21.         }
  22.     }
  23.     else
  24.     {
  25.         if(b>c)
  26.         {
  27.             cout<<b<<"is the largest\n";
  28.         }
  29.         else
  30.         {
  31.             cout<<c<<"is the largest\n";
  32.         }
  33.     }
  34.    

  35.     if(a<b)
  36.     {
  37.         if(a<c)
  38.         {
  39.             cout<<a<<"is the smallest\n";
  40.         }
  41.         else
  42.         {
  43.             cout<<c<<"is the smallest\n";
  44.         }
  45.     }
  46.     else
  47.     {
  48.         if(b<c)
  49.         {
  50.             cout<<b<<"is the smallest\n";
  51.         }
  52.         else
  53.         {
  54.             cout<<c<<"is the smallest\n";
  55.         }
  56.     }
  57.    
  58.        return 0;
  59. }
复制代码
  1. #include<iostream>
  2. using namespace std;

  3. int main()
  4. {
  5.     int x=3;
  6.     while(x>0)
  7.     {
  8.         cout<<"x="<<x<<"\n";
  9.         x --;
  10.     }
  11.     return 0;
  12. }
复制代码
话说x --;的那个部分放++的话
不懂会跑到几时的说~

回复 #14 虚空使者 的帖子

goodhermit95
2008-9-24 09:36 PM
你这些code在教我C++
这个解释很吃力的说

回复 #15 goodhermit95 的帖子

虚空使者
2008-9-24 09:44 PM
话说C++学了是用在什么方面的?
听很多人说Java比较有用~
zechs
2008-9-24 09:58 PM
原帖由 虚空使者 于 2008-9-24 04:13 PM 发表
今天又学了一些比较复杂的code...
不过对高手来说还是太简单了吧...
话说头脑不厉害转的话要学写code有点吃力~#include
using namespace std;

int main()
{
    //declare three integers
    int a,b ...


应该会跑到2147483647(integer的max)然后error或停着。

回复 #17 zechs 的帖子

goodhermit95
2008-9-24 10:25 PM
这个是固定号码的啊?不是给使用者输入?

回复 #16 虚空使者 的帖子

goodhermit95
2008-9-24 10:26 PM
我什么都不讲,不然会被JAVA或者C++支持者骂
zechs
2008-9-24 10:40 PM
原帖由 goodhermit95 于 2008-9-24 10:25 PM 发表
这个是固定号码的啊?不是给使用者输入?


是的,一开始老师都是这么教的啦~
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2026-4-27 09:16 PM , Processed in 0.097799 second(s), 20 queries .

Powered by Discuz! X2.5 © 2001-2012 Comsenz Inc.

本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved

Dedicated Server powered by iCore Technology Sdn. Bhd.

合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部