小编Noo*_*der的帖子

尽管我提供了参数,为什么我在这里得到垃圾值?

#include <iostream>
#include <math.h>
#include <conio.h>
using namespace std;

class Triangle
{
public:
    int a, b, c;
    void getdata();
    int peri(int a, int b, int c)
    {
        return a + b + c;
    }
    float s;
    float area;
    float Area(int a, int b, int c)
    {
        s = (a + b + c) / 2;
        area = sqrt(s * (s - a) * (s - b) * (s - c));
        cout << area;
    }

};

void Triangle::getdata()
{
    cin >> …
Run Code Online (Sandbox Code Playgroud)

c++ class object area

1
推荐指数
1
解决办法
579
查看次数

尽管一切都声明得很好,为什么我会收到错误?

#include <stdio.h>\n#include <stdlib.h>\n\nint main()\n{\n    int *ptr;\n    int n;\n\n    printf("Enter the no of elements you want in an array1:");\n    scanf("%d",&n);\n    printf("The no of elements in array 1 would be %d",n);\n\n    ptr=(int*)malloc(n*sizeof(int));\n    if(ptr==NULL){\n        printf("Memory not alloted ");\n    }\n    else{\n        printf("Memory successfully alloted using malloc");\n    }\n\n    printf("The elements of array 1 are:");\n    for(int i=0;i<n;i++){\n        ptr[i]=2*i;\n        printf("%d",ptr[i]);\n    }\n    free(ptr);\n    printf("Memory has been successfully freed\\n");\n\n    int *ptr1,n1;\n    printf("Enter the no of elements you want in an array2:\\n");\n    scanf("%d",&n1);\n    printf("The no of elements in array 2 …
Run Code Online (Sandbox Code Playgroud)

c malloc free realloc calloc

1
推荐指数
1
解决办法
82
查看次数

标签 统计

area ×1

c ×1

c++ ×1

calloc ×1

class ×1

free ×1

malloc ×1

object ×1

realloc ×1