C/C++の宿題を片付け ..
[2ch|▼Menu]
855:デフォルトの名無しさん
08/11/15 19:29:32
}
struct mycomplex cinput(void) {
struct mycomplex z;
scanf("%f %f",&z.re,&z.im);
return z; }
void cprint(struct mycomplex z) {
printf("複素数 = %f + i*%f\n",z.re,z.im); }
struct mycomplex wa(struct mycomplex a, struct mycomplex b) {
struct mycomplex z = { a.re+b.re, a.im+b.im };
return z; }
struct mycomplex sa(struct mycomplex a, struct mycomplex b) {
struct mycomplex z = { a.re-b.re, a.im-b.im };
return z; }
struct mycomplex seki(struct mycomplex a, struct mycomplex b) {
struct mycomplex z = { a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re };
return z; }
struct mycomplex shou(struct mycomplex a, struct mycomplex b) {
struct mycomplex z = {
(a.re*b.re + a.im*b.im) / (b.re*b.re + b.im*b.im),
(a.im*b.re - a.re*b.im) / (b.re*b.re + b.im*b.im)
};
return z; }
double cabs(struct mycomplex a) {
return hypot(a.re, a.im); }
すいません、動かないんで何処が違うか教えてください
854の続きです



856:デフォルトの名無しさん
08/11/15 19:32:14
>>853
#include<stdio.h>
void pp(int *x)
{
printf("変数xのアドレスは 0x%p です\n", x);
printf("変数xの値は %d です\n", *x);
}
int main(void)
{
int x;
fputs("? ", stdout);
scanf("%d", &x);
pp(&x);
return 0;
}

857:デフォルトの名無しさん
08/11/15 19:35:21
>>855
見づらいし
インデントしなおすのもめんどくさいから
素直にろだにあげろカス

858:デフォルトの名無しさん
08/11/15 19:37:24
>>855
carbs → acabs

859:デフォルトの名無しさん
08/11/15 19:49:51
>>854
関数宣言を main の外へ出せ

860:デフォルトの名無しさん
08/11/15 20:07:38
859の方
わからないので、8036でアップいましたので修正お願いします
ほかの方も教えてくれるとありがたいです

861:デフォルトの名無しさん
08/11/15 20:13:17
C++です。
二つの整数値を読み込んで、小さい方の数以上で大きい方の数以下の整数を全て加えた値を表示するプログラムを作りたいんです
 
 
整数1は37
整数2は28
28〜37までの全整数の和は325
for文は使わずにお願いします。
 
 
よろしくお願いしますm(_ _)m



862:デフォルトの名無しさん
08/11/15 20:19:13
>>860
関数宣言を main 関数の外へ
scanf のフォーマットが違った。 %f -> %lf
main 関数の最後に return 0; を追加
URLリンク(kansai2channeler.hp.infoseek.co.jp)

863:デフォルトの名無しさん
08/11/15 20:26:58
>>859
別に関数宣言は問題ではないと思うが

標準ライブラリのcabs()と被るのでacabs()に名前変更
main()には、return 0;でもつけてね
cinput()内のscanf()は、%fではなくて%lfにする
shou()内の(b.re * b.re + b.im * b.im) != 0 を保証すべき
acabs()でhypot()呼んでいるので、必要に応じてリンクする


最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4994日前に更新/337 KB
担当:undef