3回目の搭乗実験2

1894 ワード

2.
#include <iostream>
using namespace std;
void main()
{
	int a,b;
	cout<<"     :"<<endl;
	cin>>a;
	cout<<"     :"<<endl;
	cin>>b;
	if(b==1||b==3||b==5||b==7||b==8||b==10||b==12)
		cout<<"  31 ";
	else if(b==2)
	{
		if(a%4==0)
			if(a%100!=0)
				cout<<"  28 ";
			else
				cout<<"  29 ";
			if(a%400==0&&a%100!=0)
				cout<<"  29 ";
	}
	else if(b==4||b==6||b==9||b==11)
	cout<<"  30 ";
}

3.
#include <iostream>  
using namespace std;  
int main()  
{
	double a,c,d;  
    char b;  
    cout<<"       :"<<endl ;  
    cin >>a;  
    cout<<"====    ==== 
1. 3
2. 6
3.
4.
5.
6. "<<endl ; cout <<" "<<endl; cin >>b; switch(b) { case '1':c=a*0.031*0.25;break ; case '2':c=a*0.033*0.5;break ; case '3':c=a*0.035*1;break; case '4':c=a*0.044*2;break; case '5':c=a*0.050*3;break; case '6':c=a*0.050*5;break; default :cout <<" error
"; } d=a+c; cout <<" :"<<c<<" "<<endl; cout <<" :"<<d<<" "<<endl ; return 0; }

4.
#include <iostream>
#include <cmath>
using namespace std;
void main ()
{
	double x,y;
	cout<<"   x  :";
	cin>>x;
	if(x<2)
		y=x;
	else if(x>=2&&x<6)
		y=x*x+1;
	else if(x>=6&&x<10)
		y=sqrt(x+1);
	else
		y=1/(x+1);
	cout<<"y   :"<<y;
}