//---------------------------------------------------------------------------
// 以下の 3つのソース
// ・ipowruijo.h
// ・ipowruijo.c
// ・kadai143.c
// を用意し、
// $ gcc -o kadai143 -Wall kadai143.c ipowruijo.c
// でビルドして kadai143 を作成
//---------------------------------------------------------------------------
// ipowruijo.h
#ifndef __IPOWRUIJO_H__
#define __IPOWRUIJO_H__
extern double ruijo( double y, int m) ;
extern double ipow( double x, int n) ;
#endif//__IPOWRUIJO_H__
// End of ipowruijo.h
//---------------------------------------------------------------------------
// ipowruijo.c
#include "ipowruijo.h"
double ruijo( double y, int m)
{
int i;
double mult;
mult = 1.0 ;
for ( i = 0 ; i < m; i++ ) {
mult *= y;
}
return mult;
}
double ipow( double x, int n)
{
double res;
int i;
if ( n >= 0 ) {
res = ruijo( x, n) ;
} else {
res = 1.0 / ruijo( x, - n) ;
}
return res;
}
// End of ipowruijo.c
//---------------------------------------------------------------------------
// kadai143.c
// 参考課題
#include <stdio.h>
#include "ipowruijo.h"
int main( )
{
double num, ans;
int i;
for ( i = - 5 ; i <= 5 ; i++ ) {
ans = ipow( num, i) ;
printf ( "%f の %d 乗の値:%f\n " , num
, i
, ans
) ; }
return 0 ;
}
// End of kadai143.c
//---------------------------------------------------------------------------
Ly8tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0KLy8gIOS7peS4i+OBriAz44Gk44Gu44K944O844K5Ci8vICAgIOODu2lwb3dydWlqby5oCi8vICAgIOODu2lwb3dydWlqby5jCi8vICAgIOODu2thZGFpMTQzLmMKLy8gIOOCkueUqOaEj+OBl+OAgQovLyAgICAkIGdjYyAtbyBrYWRhaTE0MyAtV2FsbCAga2FkYWkxNDMuYyBpcG93cnVpam8uYwovLyAg44Gn44OT44Or44OJ44GX44GmIGthZGFpMTQzIOOCkuS9nOaIkAovLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS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8uaD4KI2luY2x1ZGUgImlwb3dydWlqby5oIgoKaW50IG1haW4oKQp7CiAgICBkb3VibGUgbnVtLCBhbnM7CiAgICBpbnQgaTsKCiAgICBwcmludGYoIuaVtOaVsOOCkuWFpeWKm+OBl+OBpuOBj+OBoOOBleOBhFxuIik7CiAgICBzY2FuZigiJWxmIiwgJm51bSk7CgogICAgZm9yIChpID0gLTU7IGkgPD0gNTsgaSsrKSB7CiAgICAgICAgYW5zID0gaXBvdyhudW0sIGkpOwogICAgICAgIHByaW50ZigiJWYg44GuICVkIOS5l+OBruWApO+8miVmXG4iLCBudW0sIGksIGFucyk7CiAgICB9CgogICAgcmV0dXJuIDA7Cn0KCi8vIEVuZCBvZiBrYWRhaTE0My5jCi8vLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tCg==
compilation info
prog.c:21:23: error: ipowruijo.h: No such file or directory
prog.c: In function ‘ipow’:
prog.c:38: warning: unused variable ‘i’
prog.c: In function ‘main’:
prog.c:62: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
stdout