![]() |
PCDVD數位科技討論區
(https://www.pcdvd.com.tw/index.php)
- 疑難雜症區
(https://www.pcdvd.com.tw/forumdisplay.php?f=34)
- - 誰可以幫我寫出一個簡單的程式....QQ~!
(https://www.pcdvd.com.tw/showthread.php?t=465775)
|
---|
引用:
我用MS Visual Studio 2003 裡的 VC.NET(7.0) 試過了, 已經不會出現error了,執行也正確, 但在default warning level 3下,還是會給個warning: warning C4288: nonstandard extension used : 'i' : loop control variable declared in the for-loop is used outside the for-loop scope; it conflicts with the declaration in the outer scope |
參與一下漏斗型的討論:
代碼:
#include "iostream" using namespace std; void main() { for(int y = 0; y < 7; ++y) { for(int x = 0; x < 7; ++x) { if(y <= 3) { if((y == 0) || ((x >= y) && ((x + y) <= 6))) { cout << "*"; } else { cout << " "; } } else { if((y == 0) || ((x <= y) && ((x + y) >= 6))) { cout << "*"; } else { cout << " "; } } } cout << endl; } } |
引用:
很多大大PO的程式碼已經不是純C的語法了吧?... :flash: 會害人... 你還是研究一下書吧 |
引用:
你是說這一個嗎? :ase: #include <iostream> using namespace std; int main() { int y; for(y=0; y<1; y++) { cout<<"*"<<endl; cout<<"**"<<endl; cout<<"***"<<endl; cout<<"****"<<endl; cout<<"*****"<<endl; cout<<"****"<<endl; cout<<"***"<<endl; cout<<"**"<<endl; cout<<"*"<<endl; } return 0; } |
引用:
借一下 Wallace 兄的程式 #include <iostream> using namespace std; int main() { int total=9;} |
引用:
謝謝你 我是忠實愛用者 :hungry: Linux 的開發環境真的比 M$ 好很多 |
純 C 的程式
#include <stdio.h> #ifdef __cplusplus extern "C" { #endif #define ROWCnt 9 void Case1() { int rowIdx; int idx, starCnt; printf("Case 1:\n"); for (rowIdx = 0; rowIdx < ROWCnt; rowIdx++) { starCnt = ((rowIdx < ROWCnt / 2) ? rowIdx + 1 : ROWCnt - rowIdx); for (idx = 0; idx < starCnt; idx++) printf("*"); printf("\n"); } printf("\n"); } void Case2() { int rowIdx; int idx, spaceCnt, starCnt; printf("Case 2:\n"); for (rowIdx = 0; rowIdx < ROWCnt; rowIdx++) { spaceCnt = ((rowIdx < ROWCnt / 2) ? rowIdx : ROWCnt - rowIdx - 1); starCnt = ROWCnt - 2 * spaceCnt; for (idx = 0; idx < spaceCnt; idx++) printf(" "); for (idx = 0; idx < starCnt; idx++) printf("*"); printf("\n"); } printf("\n"); } int main() { Case1(); Case2(); return 0; } #ifdef __cplusplus } #endif |
大家討論那麼多,不論是從compile environment或compile tools,
但最主要的是「誰可以幫我寫出一個簡單的程式....QQ~! 」 還是printf最簡單:jolin :jolin |
我用你們寫的程式去學校跑~
沒有一個是對的= = 美一個錯誤都在5個以上~瘋掉~! |
忘了提醒你,
寫程式不用很多時間, 因為大部份都花在debug!! |
所有的時間均為GMT +8。 現在的時間是12:16 AM. |
vBulletin Version 3.0.1
powered_by_vbulletin 2025。