编程

对于一个刚刚踏入软件的新手来说,基础是最重要的,所以我会把自己所写的编码记录下来;记录自己的学习路程;

#include <iostream.h>
class yuan
{
int r;
public:
void set(int x)
{
r=x;
}
float calmianji()
{
return 3.14*r*r;
}
};
void main()
{
yuan y1;
y1.set(4);
cout<<"mianji"<<y1.calmianji()<<endl;
cout<<"neicun"<<sizeof(y1)<<endl;
}

第一个

#include <iostream.h>
void main()
{
int dight,num;
cout<<"输入一个整数:";cin>>num;
cout<<"反向显示结果:";
while (num!=0)
{
dight=num % 10;
num=num / 10;
cout << dight;
}
cout << endl;
}

第二次

#include <iostream.h>
class rectangle
{
private:
int len,wid;
public:
void fun()
{
cout<<"请输入长和宽:"<<endl;
cin>>wid>>len;
}
int calarea()
{
return len*wid;
}
int calzhouchang()
{
return (len+wid)*2;
}

};
void main()
{
rectangle rect1;
rect1.fun();
int sum1,sum2;
sum1=rect1.calarea();
sum2=rect1.calzhouchang();
cout<<"面积"<<sum1<<endl;
cout<<"周长"<<sum2<<endl;
}

第三个

#include <iostream.h>
class A
{
private:
char x,y;
public:
void set(char a)
{
x=a;
y=x-32;
}
void show()
{
cout<<x<<" "<<y<<endl;
}
};
void main()
{
A c1;
c1.set('a');
c1.show();
}
字母大小写转换


#include <iostream.h>
class testcacl
{
private:
int i,j,k;
public:
void cacl()
{
int x,y,z;
i=5,j=6,k=8;
x=i+j+k;
cout<<"x="<<x<<endl;
}
};
void main()
{
testcacl t1;
t1.cacl();
}
#include <iostream.h>
void main()
{
int a,b,c;
a=b=10;
c=++a;
//cout<<c<<" "<<a<<endl;
c=--b;
//cout<<c<<" "<<b<<endl;
c=a*(a++);
cout<<c<<" "<<a<<endl;
}

#include <iostream.h>
class yuan
{
int r;
public:
void set(int x)
{
r=x;
}
float calmianji()
{
return 3.14*r*r;
}
};
void main()
{
yuan y1;
y1.set(4);
cout<<"mianji"<<y1.calmianji()<<endl;
cout<<"neicun"<<sizeof(y1)<<endl;
}


#include <iostream.h>
class yuan
{
private:
int r;
public:
void fun()
{
cout<<"请输入半径:"<<endl;
cin>>r;
}
float calarea()
{
return 3.14*r*r;
}
float calzhouchang()
{
return 2*3.14*r;
}

};
void main()
{
yuan y1;
y1.fun();
float sum1,sum2;
sum1=y1.calarea();
sum2=y1.calzhouchang();
cout<<"mianji"<<sum1<<endl;
cout<<"zhouchang"<<sum2<<endl;
}
#include <iostream.h>
class yuan
{
int r;
public:
void set(int a)
{
r=a;
}
float calarea()
{
return r*r*3.14;
}
float calzhouchang()
{
return 2*3.14*r;
}
};
void main()
{
yuan y1;
y1.set(6);
cout<<"area"<<y1.calarea()<<endl;
cout<<"zhouchang"<<y1.calzhouchang()<<endl;

}
这些都是我所写的;以后还会慢慢记录,这是我的成长经历啊;

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值