一、题目
1、整数A ,正整数B已知,例:A=3 B=2 。
操作:输出 A/B的非转换值C 、转换值D和C、D的差值
形式【1】:
#include<iostream>
using namespace std;
int main()
{
//1
int A=3;
int B=2;
float C,D,E;
//2
cout<<"C="<<A/B<<endl;
cout<<"D="<<(float)A/B<<endl;
cout<<"E="<<(float)A/B-A/B<<endl;
system("pause");
return (0);
}
形式【2】:
#include<iostream>
using namespace std;
int main()
{
//1
int A=3;
int B=2;
float C,D,E;
//4
C=A/B;
D=(float)A/B;
cout<<"C="<<C<<endl;
cout<<"D="<<D<<endl;
cout<<"E="<<D-C<<endl;
system("pause");
return (0);
}
形式【3】:
#include<iostream>
using namespace std;
int main()
{
//1
int A=3;
int B=2;
float C,D,E;
//5
cout<<"C="<<A/B<<endl;
cout<<"D="<<(float)A/B<<endl;
cout<<"E="<<D-C<<endl;
system("pause");
return (0);
}
形式【4】:
#include<iostream>
using namespace std;
int main()
{
//1
int A=3;
int B=2;
float C,D,E;
//6
C=A/B;
D=(float)A/B;
cout<<"C="<<C<<endl;
cout<<"D="<<D<<endl;
cout<<"E="<<(float)A/B-A/B<<endl;
system("pause");
return (0);
}
2、随机输入整数A ,正整数B。
操作:输出 A/B的非转换值C 、转换值D和C、D的差值E。
形式【1】:
#include<iostream>
using namespace std;
int main()
{
//3
int A,B;
float C,D,E;
cout<<"enter integer A :";
cin>>A;
cout<<endl;
cout<<"enter positive integer B :";
cin>>B;
//2
cout<<"C="<<A/B<<endl;
cout<<"D="<<(float)A/B<<endl;
cout<<"E="<<(float)A/B-A/B<<endl;
system("pause");
return (0);
}
形式【2】:
#include<iostream>
using namespace std;
int main()
{
//3
int A,B;
float C,D,E;
cout<<"enter integer A :";
cin>>A;
cout<<endl;
cout<<"enter positive integer B :";
cin>>B;
//4
C=A/B;
D=(float)A/B;
cout<<"C="<<C<<endl;
cout<<"D="<<D<<endl;
cout<<"E="<<D-C<<endl;
system("pause");
return (0);
}
形式【3】:
#include<iostream>
using namespace std;
int main()
{
//3
int A,B;
float C,D,E;
cout<<"enter integer A :";
cin>>A;
cout<<endl;
cout<<"enter positive integer B :";
cin>>B;
//5
cout<<"C="<<A/B<<endl;
cout<<"D="<<(float)A/B<<endl;
cout<<"E="<<D-C<<endl;
system("pause");
return (0);
}
形式【4】:
#include<iostream>
using namespace std;
int main()
{
//3
int A,B;
float C,D,E;
cout<<"enter integer A :";
cin>>A;
cout<<endl;
cout<<"enter positive integer B :";
cin>>B;
//6
C=A/B;
D=(float)A/B;
cout<<"C="<<C<<endl;
cout<<"D="<<D<<endl;
cout<<"E="<<(float)A/B-A/B<<endl;
system("pause");
return (0);
}
二、结果运行图
题目1:
形式【1】=【2】=【4】:
形式【3】:
题目2:
形式【1】=【2】=【4】:
形式【3】: