이전 질문 게시판은 새 글 쓰기를 막았습니다. [질문 게시판]을 이용바랍니다.
Date |
2009/09/14 12:13:57 |
Name |
The Beast |
Subject |
c 언어 질문 |
c언어를 오래전에 해 봤다가 다시 꺼낼일이 있어 뭔가를 돌려봤는데 문제가 발생했습니다.
컴파일을 하니
Compiling...
강정훈_2.cpp
.\강정훈_2.cpp(20) : error C3861: 'sqrt': identifier not found
.\강정훈_2.cpp(29) : error C2731: 'main' : function cannot be overloaded
.\강정훈_2.cpp(28) : see declaration of 'main'
.\강정훈_2.cpp(33) : error C3861: 'printf': identifier not found
.\강정훈_2.cpp(34) : error C3861: 'scanf': identifier not found
.\강정훈_2.cpp(36) : error C2370: 'phi' : redefinition; different storage class
.\강정훈_2.cpp(30) : see declaration of 'phi'
.\강정훈_2.cpp(37) : error C3861: 'printf': identifier not found
Build log was saved at "file://c:\Documents and Settings\LG\My Documents\Visual Studio 2008\Projects\강정훈_2\강정훈_2\Debug\BuildLog.htm"
강정훈_2 - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
라고 뜨는데 아마 제가 뭔가 초기 설정이 안되이었던 모양인데 무었이 문제였을까요? 소스는 간단한겁니다.
// 강정훈_2.cpp : main project file.
#include "stdafx.h"
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
return 0;
}
double PHI(int N)
{
double d, xi, yi, phi;
d = 2.0 / (double)N;
phi = 0;
for(int i=0;i<N-1;i++){
xi = d*i-1.0;
yi = sqrt(1-xi*xi);
phi += (d*yi);
}
phi = 2.0*phi;
return phi;
}
int main (int argc, char *argv[])
{
double d, xi, yi, phi;
int N;
printf("\n enter the iteration number = ");
scanf("%d",&N);
double phi = PHI(N);
printf("\n phi = %10.8lf \n\n",phi);
return 0;
}
이상하게 머리속에 남아있는게 없어서 큰일이네요..
|
통합규정 1.3 이용안내 인용
"Pgr은 '명문화된 삭제규정'이 반드시 필요하지 않은 분을 환영합니다.
법 없이도 사는 사람, 남에게 상처를 주지 않으면서 같이 이야기 나눌 수 있는 분이면 좋겠습니다."
|