Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <math.h>
- struct complex_t* set(struct complex_t* cp, float re, float im, int *err_code);
- struct complex_t
- {
- float re;
- float im;
- };
- int main(){
- struct complex_t number1;
- printf("Podaj pierwsza liczbe: ");
- if(scanf("%f %f",&number1.re,&number1.im)!=2){
- printf("Incorrect input");
- return 1;
- }
- struct complex_t number2;
- printf("Podaj druga liczbe: ");
- if(scanf("%f %f",&number2.re,&number1.im)!=2){
- printf("Incorrect input");
- return 1;
- }
- float modul_1 = complex_abs(&number1,NULL);
- float modul_2 = complex_abs(&number2,NULL);
- return 0;
- }
- struct complex_t* set(struct complex_t* cp, float re, float im, int *err_code){
- if (cp == NULL){
- return *err_code = NULL;
- }
- cp->re = re;
- cp->im = im;
- return *err_code = cp;
- }
- void show(const struct complex_t* cp){
- printf("");
- }
- float complex_abs(struct complex_t* cp, int * err_code){
- if(cp == NULL){
- return *err_code = 1;
- }
- float modul = sqrt(pow(cp->re,2)+pow(cp->im,2));
- return modul;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement