This file contains 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
//901-2 | |
#include<stdlib.h> | |
#include<stdio.h> | |
void exchange(double*, double*);//宣告副程式,名字叫exchange | |
//呼叫時要傳入兩個雙精浮點數的記憶體位置 | |
int main() { | |
double c, d;//宣告兩個雙精浮點數c和d | |
printf("請輸入兩個浮點數(數字跟數字中間請以空白間隔)");//列印文字 | |
scanf("%lf %lf", &c, &d);//讓使用者輸入兩個數字 | |
printf("c:%lf d:%lf\n", c, d);//列印變數 |
This file contains 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
//902 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
int i, c[6];//宣告整數,宣告整數陣列 | |
c[0] = c[1] = c[2] = c[3] = c[4] = c[5] = 0;//整數陣列設為0 | |
for (i = 0; i<6; i++) {//從0開始到5 會出現0 1 2 3 4 5 共6次 | |
c[i] = rand() % 49 + 1;//整數陣列的第i個等於亂數產生0~48,+1之後變成1~49 | |
while ((c[i] == c[0] && i != 0) || (c[i] == c[1] && i != 1) || (c[i] == c[2] && i != 2) || (c[i] == c[3] && i != 3) || (c[i] == c[4] && i != 4) || (c[i] == c[5] && i != 5)) { | |
//如果整數陣列中第i個等於第0~5個的話 |
This file contains 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
//903 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int greater60(int*, int);//宣告整數greater60,要傳入整數記憶體位址和整數 | |
int main() { | |
int data[6];//宣告整數陣列 | |
int i;//宣告整數 | |
for (i = 0; i<6; i++) {//i從0開始到5,共會出現6次 | |
printf("請輸入第%d個分數:", i + 1);//顯示文字和i+1(1~6) | |
scanf("%d", &data[i]);//讓使用者輸入數字 |
This file contains 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
//904-1 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() {//r讀取 w寫入 a讀寫 | |
FILE *fi;//宣告檔案指標 | |
char name[20];//宣告字元陣列 | |
int score;//宣告變數 | |
fi = fopen("score.dat", "w");//使用寫入的方式開啟檔名為score.dat的檔案 | |
do { | |
printf("請輸入學生的姓名(分數輸入負的分數時結束):"); |
This file contains 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
//904-2 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
FILE *fi;//宣告檔案指標 | |
char name[20];//宣告字元陣列 | |
int score;//宣告變數 | |
fi = fopen("score.dat", "r"); //使用讀取的方式開啟檔名為score.dat的檔案 | |
while (fscanf(fi, "%s %d", name, &score) != EOF)//如果讀不到資料時跳出 | |
printf("%s的C語言分數是%d\n", name, score); //列印名字和分數 |
This file contains 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
//905-1 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
FILE *fi;//宣告檔案指標 | |
double ss;//宣告雙精浮點數 | |
fi = fopen("dnumber.dat", "w");//使用寫入的方式開啟檔名為dnumber.dat的檔案 | |
do { | |
printf("請輸入浮點數:"); |
This file contains 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
//905-2 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
FILE *fi;//宣告檔案指標 | |
double ss;//宣告雙精浮點數 | |
fi = fopen("dnumber.dat", "r");//使用讀取的方式開啟檔名為dnumber.dat的檔案 | |
while (fscanf(fi, " %lf ", &ss) != EOF) {//如果讀不到資料就跳出 | |
printf("%.2lf\n", ss);//列印雙精浮點數 | |
} |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApp2 | |
{ | |
class Program | |
{ |
This file contains 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 "pch.h" | |
#include <iostream> | |
#include "stdlib.h" | |
#include "time.h" | |
#include "string.h" | |
#define SIZE 7 | |
#define DIM 21 | |
// A,B,C,D,E,F,ERD | |
char ERD[SIZE][SIZE] = { {0,1,0,0,0,0,0},//A | |
{1,0,2,0,4,0,0},//B |
This file contains 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 "pch.h" | |
#include <iostream> | |
#include "stdlib.h" | |
#include "time.h" | |
#include "string.h" | |
#define SIZE 7 | |
#define DIM 21 | |
// 0, 1, 2 3 4 5 6 | |
// A, B, C, D, E, F, ERD | |
char ERD[SIZE][SIZE] = { { 0, 1, 1, 0, 0, 0, 0 },//0 |