首页 > 其他分享 >4.27

4.27

时间:2023-04-27 22:46:14浏览次数:36  
标签:widen cout int double length rectangle 4.27

 1 #include<iostream>
 2 using namespace std;
 3 class Rectangle {
 4 public:
 5     int j;
 6     void area(int X = 0, int Y = 0, int A = 0, int B = 0);
 7 private:
 8     int x, y, a, b;
 9 };
10 void Rectangle::area(int X, int Y, int A, int B) {
11     x = X; y = Y; a = A; b = B;
12     j = (a - x) * (b - y);
13 }
14 int main() {
15     int x, y, a, b;
16     Rectangle rectangle;
17     cout << "输入左下角坐标x和y" << endl;
18     cin >> x >> y;
19     cout << "输入右上角坐标为a和b" << endl;
20     cin >> a >> b;
21     rectangle.area(x, y, a, b);
22     cout << "该矩形面积为:" << rectangle.j << endl;
23     return 0;
24 }
 1 #include <iostream>
 2 using namespace std;
 3 class rectangle { 
 4 public:
 5     rectangle(double len, double wide) {
 6         length = len;
 7         widen = wide;
 8     }
 9     ~rectangle() {};
10     double getarea() { return length * widen; }
11     double getlength() { return length; }
12     double getwiden() { return widen; }
13 private:
14     double length;
15     double widen;
16 };
17 void main() { 
18     double length, widen;
19     cout << "请输入矩形的长:";
20     cin >> length;
21     cout << "请输入矩形的宽:";
22     cin >> widen;
23     rectangle r(length, widen); 
24     cout << "长为" << length << ",宽为" << widen << "的矩形面积是" << r.getarea() << endl;
25 }
26  
 1 #include <iostream>
 2 using namespace std;
 3 class circle {  
 4 public:
 5     circle(double radius) {
 6         r = radius;
 7     }
 8     ~circle() {};  
 9     double getarea() { return 3.14 * r * r; }
10 private:
11     double r;
12 };
13 void main() { 
14     cout << "请输入圆的半径:";
15     double radius;
16     cin >> radius;
17     circle r(radius);
18     cout << "圆的面积是:" << r.getarea() << endl;  
19 }

 

标签:widen,cout,int,double,length,rectangle,4.27
From: https://www.cnblogs.com/lijianlongCode13/p/17360441.html

相关文章

  • 4.27趣味百题4.4
    一问题描述 二设计思路最终分解为一个分子为1的分数可以用while循环执行根据埃及分数的特性对其不断分裂三流程图 四代码实现#include<iostream>usingnamespacestd;intmain(){inta=0,b=0,c=0;cout<<"请输入一个真分数先输入分子后输入分母"<<endl;cin>>a>>......
  • 4.27打卡
     #include<bits/stdc++.h>usingnamespacestd;classTime{private:intminute;inthour;public:voidset(inth,intm){minute=m;hour=h;}friendintoperator-(Time,Time);};intoperator-(......
  • 2023.4.27
     1//实验六任务22#include<iostream>3#include<string>4usingnamespacestd;5classPeople6{7public:8People(){}9~People(){}10voidsetValue(intm,stringstr)11{12age=m;13name=str;......
  • 2023.4.27编程一小时打卡
    一、问题描述:建立一个向量容器的实例s,不断对s调用push_back向其中增加新的元素,观察在此过程中s.capacity()的变化。二、解题思路:首先,编写一个向量容器vector<int>s,利用循环对其进行不断调用push_back,再输出它的capacity()函数观察它向量容器的容量的变化。三、代码实现:1#in......
  • 4.27
    #include<stdio.h>voidprint(ints[]);intjudge(intc[]);intj=0;main(){intsweet[10]={10,2,8,22,16,4,10,6,14,20};inti,t[10],l;printf("child12345678910\n");printf("......................\n");printf("tim......
  • 2023.4.27
    //Parent.vue<template>   <childv-model="value"></child></template><script>exportdefault{   data(){       return{           value:1       }   }}//Child.vue<template>   <input:value="value&......
  • 4.27 1.9
    一、问题描述N个有序整数数列已放在一堆数组中,利用二分法查找整数m在数组中的位置。若找到,输出其值,反之,输出“Notbefound!”。二、分析N个有序数应存放在数组中,根据数组下标的取值范围知指针low和high的初值分别为0N-1。除了三个指针变量low、high、mid之外还需要一个变......
  • 2023.4.27——软件工程日报
    所花时间(包括上课):3h代码量(行):0行博客量(篇):1篇今天,上午学习,下午学习并开会。我了解到的知识点:1.了解了一些数据库的知识;2.了解了一些python的知识;3.了解了一些英语知识;5.了解了一些Javaweb的知识;4.了解了一些数学建模的知识;6.了解了一些计算机网络的知识;......
  • 4.27打卡
    一、问题描述:求某一范围内完数的个数。如果一个数等于它的因子之和,则称该数为“完数”(或“完全数”)。例如,6的因子为1,2,3,而6=1+2+3,因此6是“完数”。二、设计思路:根据完数的定义,解决本题的关键是计算出所选取的整数i(i的取值范围不固定)的因子(因子就是所有可以整除这个数的数),将......
  • ue4.27 VScode 找不到源文件修复方法
    修改.vscode目录下compileCommands_***.json多个文件 { "file":"E:\\\\UnrealProjects\\\\wargame_sanguo\\\\Source\\\\wargame_sanguo\\\\.vs\\\\ProjectSettings.json", "command":"E:\\UnrealProjects\\w......