«یا اللهُ یا رَبِّ یا حَیُّ یا قَیّوم یا ذَالجَلالِ وَ الاکرام اَسئَلُکَ بِاسمِکَ اَلعَظیم اَلاَعظَم اَن تَرزُقَنی رِزقاً حَلالاً طَیِّباً بِرَحمَتِکَ الواسِعَه یا اَرحَمَ الرّاحِمِین.»
جمع دو عدد پیچیده با استفاده از struct یا ساختارها در CPP :: گیم اور _ بازیسازی با unity + مطالب متفرقه

گیم اور _ بازیسازی با unity + مطالب متفرقه

آموزش های علمی با اجازه ی خدا تقدیم به هرکس خدا بخواد

آموزش های علمی با اجازه ی خدا تقدیم به هرکس خدا بخواد

به نام خدا
---
سوالی بود بذارید
نظر خصوصی نذارید
پاسخش سخته

بایگانی
پیوندها

gameover.blog.ir

#include <iostream>

using namespace std;

typedef struct complex{
    float real;
    float imag;
}complex;

complex add(complex n1,complex n2);

int main(){
    complex n1,n2,temp;
    cout << "For 1st complex number " << endl;
    cout << "Enter real and imaginary respectively:" << endl;
    cin >> n1.real >> n1.imag;
    cout << endl << "For 2nd complex number " << endl;
    cout << "Enter real and imaginary respectively:" << endl;
    cin >> n2.real >> n2.imag;
    temp=add(n1,n2);    
    cout << "Sum: " << "(" << temp.real << ")" << "+" << "(" << temp.imag << ")" << "i";
    return 0;
}

complex add(complex n1,complex n2){
      complex temp;
      temp.real=n1.real+n2.real;
      temp.imag=n1.imag+n2.imag;
      return(temp);
}

Output



For 1st complex number
Enter real and imaginary respectively: 2.3
4.5

For 2nd complex number
Enter real and imaginary respectively: 3.4
5
Sum=(5.7) + (9.5)i
موافقین ۰ مخالفین ۰ ۹۵/۰۷/۱۶
مدیرکل

نظرات (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی