This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <GL/glut.h> ///第18行留下來,使用 GLUT外掛 | |
| void display() | |
| { | |
| glColor3f(1,1,0); | |
| glutSolidTeapot( 0.3 ); | |
| glutSwapBuffers(); | |
| } | |
| int main(int argc, char *argv[]) ///第138行, main()函式 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 100 /* func sample. coast creation */ | |
| 110 float s | |
| 120 while s<1 or s>=2 | |
| 130 input "ratio 1 to 2";s | |
| 140 endwhile | |
| 150 s = (s-1)/10+1 | |
| 160 screen 1,2,1,1 | |
| 170 s=sqr(s*s-1) | |
| 180 float x0=100, x1=412, y0=0, y1=0 | |
| 190 fractal(x0,x1,y0,y1,1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include "IntegerSet.h" | |
| using namespace std; | |
| IntegerSet::IntegerSet(){ | |
| bool v[50] = {}; //但是你這裡初始化的,是local區域變數,與 IntegerSet 裡的 v[50] 沒有關係 | |
| } | |
| IntegerSet::IntegerSet(int n, int y[]){ | |
| bool v[50] = {}; //但是你這裡初始化的,是另一個local區域變數,與 IntegerSet 裡的 v[50] 沒有關係 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://www.facebook.com/groups/1403852566495675/posts/3295538717327041/ | |
| // 每3位隔逗號 (銘傳大學阿平老師出的題目) | |
| #include <stdio.h> | |
| int main() | |
| { | |
| long long int n=123456789012345;//很長很長的整數,最多19位吧 | |
| int ans[20], len=0;//用ans[i]陣列來存每個位數的值 | |
| for(int i=0; i<20; i++){//陣列開20格,一定夠用啦 | |
| ans[i] = n % 10; //把個位數存起來 | |
| n = n / 10;//n被剝皮,就變少了 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //回覆網友 雙人的小遊戲 https://www.facebook.com/groups/1403852566495675/posts/3188292548051659/ | |
| //我寫了一段程式給你參考。鍵盤左邊的 wsad 控制 玩家1, 右邊方向鍵控制 玩家2。 | |
| //這段程式的重點: (1) 位置 x y 配合 速度 vx vy 來更新 | |
| //(2) 按下按鍵時, 要去改速度 | |
| //(3) 放開按鍵時, 就把速度設0 | |
| //建議寫程式時: File-Preference 字型調大一點,配合中文字型,截圖較清楚 | |
| float x=100, y=300, x2=700, y2=300;//位置, 用來畫2位玩家 | |
| float vx=0, vy=0, vx2=0, vy2=0;//玩家的速度, 用來修改玩家的位置 | |
| void setup(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ///全刪,拿剛剛的程式來用!!! | |
| #include <opencv/highgui.h> ///使用 OpenCV 2.1 比較簡單, 只要用 High GUI 即可 | |
| #include <opencv/cv.h> | |
| #include <GL/glut.h> | |
| GLUquadric * sphere = NULL;///一個指到二次曲面的指標 | |
| int myTexture(char * filename) | |
| { | |
| IplImage * img = cvLoadImage(filename); ///OpenCV讀圖 | |
| cvCvtColor(img,img, CV_BGR2RGB); ///OpenCV轉色彩 (需要cv.h) | |
| glEnable(GL_TEXTURE_2D); ///1. 開啟貼圖功能 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <opencv/highgui.h> ///使用 OpenCV 2.1 比較簡單, 只要用 High GUI 即可 | |
| #include <opencv/cv.h> | |
| #include <GL/glut.h> | |
| int myTexture(char * filename) | |
| { | |
| IplImage * img = cvLoadImage(filename); ///OpenCV讀圖 | |
| cvCvtColor(img,img, CV_BGR2RGB); ///OpenCV轉色彩 (需要cv.h) | |
| glEnable(GL_TEXTURE_2D); ///1. 開啟貼圖功能 | |
| GLuint id; ///準備一個 unsigned int 整數, 叫 貼圖ID | |
| glGenTextures(1, &id); /// 產生Generate 貼圖ID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| program fortran_bubble | |
| character (len = 8), dimension(20) :: name | |
| integer, dimension(20) :: grade ! Total 20 students | |
| character (len = 8) :: tempName ! Temp swapping variables | |
| integer :: tempGrade | |
| open(20, file = 'student_grad.txt') | |
| do i = 1,20 | |
| read(20,*) name(i), grade(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <GL/glut.h> | |
| const GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f }; | |
| const GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; | |
| const GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; | |
| const GLfloat light_position[] = { 2.0f, 5.0f, -5.0f, 0.0f }; | |
| const GLfloat mat_ambient[] = { 0.7f, 0.7f, 0.7f, 1.0f }; | |
| const GLfloat mat_diffuse[] = { 0.8f, 0.8f, 0.8f, 1.0f }; | |
| const GLfloat mat_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f }; | |
| const GLfloat high_shininess[] = { 100.0f }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| char line[2000]; | |
| int main() | |
| { | |
| int t=1;//t=1是火車頭 2是掛勾車廂 3是掛勾車廂 4是掛勾車廂 .... | |
| while( gets(line) ){ //一次讀入 得到一整行 | |
| if(t>1) printf("\n");//火車頭不印,掛勾車廂才印 | |
| t++;//這個容易漏掉,我放前面一點,方便你看到 | |
| int freq[256]={};//別忘了陣列初始化 |
NewerOlder