###前提・実現したいこと
楕円の形状を定義している式をC言語でプログラムしたいです。
宣言の部分でエラーが出ていると思われます。
###発生している問題・エラーメッセージ
gcc ellipse1.c -lm ellipse1.c: In function ‘main’: ellipse1.c:9:18: error: invalid operands to binary ^ (have ‘double’ and ‘int’) l = a*(1.0-(int)e^2); ^ ellipse1.c:14:1: error: expected declaration or statement at end of input printf("x=%.3f y=%.3f", x,y);
###該当のソースコード
C
1#include <stdio.h> 2#include <stdlib.h> //rand() 3#include <math.h> //sin(), cos(), M_PI 4#include <time.h> //time() 5int main(void){ 6float e, a, l, r, x, y, theta; 7scanf(" %f %f", &e, &a); 8theta = rand() % 360; 9l = a*(1.0-e^2); 10r = l/(1.0 + e*cos(theta * M_PI / 180.0)); 11x = r* cos(theta*M_PI/180.0); 12y = r* sin(theta*M_PI/180.0); 13 14printf("x=%.3f y=%.3f", x,y);
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/26 22:15