Primer_Five

#include <iostream>

using namespace std;

int main()
{
    int num_1,num_2,i,add=0;
    cout << "Please enter the first numble : "<<endl;
    cin >> num_1;
    cout << "Please enter a number greater than the first number:"<<endl;
    cin >> num_2;
    for(i=num_1;i<=num_2;i++)
    {
        add+=i;
    }
    cout << "The result is :"<<add<<endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int num,add=0;
    while (num!=0)
    {
        cout << "please enter numble,If you want to end input, enter 0:" << endl;
        cin >> num;
        add+=num;
        cout << "All the accumulated input is :"<<add<<endl;
    }
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    float Dap_Interest=0,Cleo_Interest=0;
    int i=0;
    do
    {
        Dap_Interest+=100*0.1;
        Cleo_Interest+=((100+Cleo_Interest)*0.05);
        ++i;
    }
    while (Dap_Interest>Cleo_Interest);
    cout << "After the "<<i<<" year,the interest of Cleo is greater than Daphne."<<endl;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
struct car
{
    string manu_f;
    int year;
};

int main()
{
    int n,i;
    cout << "How many cars do you wish to catalog? "<<endl;
    cin >> n;
    cin.get();
    car *car_n = new car[n];
    for(i=0;i<n;i++)
    {
        cout<<"Cae #"<<i+1<<":"<<endl;
        cout<<"Please enter the make:";
        getline(cin,car_n[i].manu_f);
        cout <<endl;
        cout << "Please enter the year made :";
        cin >> car_n[i].year;
        cin.get();
        cout << endl;
    }
    cout << "Here is your collection:"<<endl;
    for(i=0;i<n;i++)
    {
        cout <<car_n[i].year<<" "<<car_n[i].manu_f<<endl;
    }

    return 0;
}
//数字输入之后要在后面加上cin.get(),不然下一个输入会直接读取上一次输入数字后留下的终止符。

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
    const int Size=100;
    char word[Size];
    int i=0;
    cout << "Enter words (to stop,type the word done):";
    while (cin >> word&&strcmp(word,"done"))
    {
       ++i;
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值