第十周项目一:程序填充题

#include <iostream>

using namespace std;

int main()
{
    int a=100;
    int b=20;
    int c,k;
    char oper;
    for(k=0; k<=9; k++)
    {
        cin>>a>>oper>>b;
        switch(oper)
        {
        case'+':
            c=a+b;
            break;
        case'-':
            c=a-b;
            break;
        case'*':
            c=a*b;
            break;
        default:
            if(b=0)c=a;
            else c=a/b;
            break;
        }
    cout<<"c="<<c<<endl;
    }
    return 0;
}

第十周项目一:程序填充题_第1张图片
#include <iostream>
#include<iomanip>
using namespace std;

int main()
{
    int a=34;
    cout<<"hex:"<<hex<<a<<endl;
    cout<<"oct:"<<setbase(8)<<a<<endl;
    cout<<"dec:"<<dec<<a<<endl;
    char *pt="China";
    cout<<setw(10)<<pt<<endl;
    cout<<setfill('*')<<setw(10)<<pt<<endl;
    double d=225.0/7.0;
    cout<<"d="<<d<<endl;
    cout<<"d="<<setprecision(4)<<d<<endl;
    cout<<"d="<<setiosflags(ios::fixed)<<d<<endl;
    cout<<setprecision(5)<<d<<endl;
    return 0;
}

第十周项目一:程序填充题_第2张图片
#include <iostream>
#include<cstdio>
using namespace std;

int main()
{
    char c1,c2,c3;
    c1=getchar();
    c2=getchar();
    cout<<c1<<" "<<c2<<endl;
    cout<<int(c1)<<" "<<int(c2)<<endl;
    c3=getchar();
    cout<<c3<<endl;
    cout<<int(c3)<<endl;
    return 0;
}

第十周项目一:程序填充题_第3张图片

你可能感兴趣的:(第十周项目一:程序填充题)