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
//801-1 | |
#include "stdafx.h" | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main() | |
{ | |
int i, j; | |
for (i = 1; i <= 5; i++) {//從1開始,一直到5 共會出現1,2,3,4,5 | |
for (j = 0; j<i; j++)//從0開始,一直到i的前一個 | |
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
//801-2 | |
#include "stdafx.h" | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main() | |
{ | |
int i, j; | |
for (i = 1; i <= 5; i++) {//從1開始,一直到5 共會出現1,2,3,4,5 | |
for (j = 6 - i; j>0; j--)//從(6-i)開始,一直到1 | |
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
//801-3 | |
#include "stdafx.h" | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main() | |
{ | |
int i, j; | |
for (i = 1; i <= 5; i++) {//從1開始,一直到5 共會出現1,2,3,4,5 | |
for (j = 0; j<5 - i; j++)printf(" ");//從(6-i)開始,一直到1 | |
for (j = 0; j<i; j++)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
//801-4 | |
#include "stdafx.h" | |
#include<stdio.h> | |
#include<stdlib.h> | |
int main() | |
{ | |
int i, j; | |
for (i = 0; i<5; i++) {//從0開始,一直到4 共會出現0,1,2,3,4 | |
for (j = 0; j<i; j++)printf(" ");//從0開始,一直到i的前一個 | |
for (j = 0; j<5 - i; j++)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
//802 | |
#include "stdafx.h" | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main() { | |
char choice[5];//宣告choice是一個字元陣列,長度為5 | |
int a = 0;//宣告a是一個整數,預設值為0 | |
while (a != 5) {//條件成立時執行 如果a不等於5就執行 | |
printf("(1)教授\n(2)副教授\n(3)助理教授\n(4)都不是\n(5)結束\n請輸入您的職稱代號:");//列印 |
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
//803 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
int i = 0, a = 0, b = 0, c = 0;//宣告整數變數 | |
int tk;//宣告tk是一個整數 | |
while (i<10) {//i從0開始到9共有10票 | |
printf("(1)小蔡\n(2)小王\n(3)小史\n請你投票:");//列印 | |
scanf("%d", &tk);//輸入整數 &為取址 | |
if (tk == 1)a++;//如果投1號,a+1 |
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
//804 | |
#include<stdlib.h> | |
#include<stdio.h> | |
double average(double*, int);//宣告副程式average是一個雙精浮點數 | |
//使用時要回傳 一個雙精浮點數的記憶體位址和一個整數 | |
int main() { | |
int i;//宣告整數 | |
double data[6];//宣告雙精浮點數陣列 | |
for (i = 0; i<6; i++) {//迴圈0~5 共會執行6次 | |
printf("請輸入第%d個浮點數:", i + 1);//顯示文字和整數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
//805-1 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
int arr[3][4], i, j, tot = 0;//宣告arr為整數二維陣列 | |
for (i = 0; i<3; i++) {//0,1,2 | |
printf("請輸入四個數字(數字之間請以空白為間隔):"); | |
for (j = 0; j<4; j++) {//控制行 | |
scanf("%d", &arr[i][j]);//把整數存入arr陣列的記憶體位址中 | |
tot += arr[i][j];//把每個輸入的數都加到tot中(計算總合) |
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
//805-2 | |
#include<stdlib.h> | |
#include<stdio.h> | |
int main() { | |
int arr[5][2], i, j, tot = 0;//宣告arr為整數二維陣列 | |
for (i = 0; i<5; i++) { | |
printf("請輸入兩個數字(數字之間請以空白為間隔):"); | |
for (j = 0; j<2; j++) { | |
scanf("%d", &arr[i][j]);//把整數存入arr陣列的記憶體位址中 | |
tot += arr[i][j];//把每個輸入的數都加到tot中(計算總合) |
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-1 | |
#include<stdlib.h> | |
#include<stdio.h> | |
void exchange(int*, int*);//宣告副程式,名字叫exchange | |
//呼叫時要傳入兩個整數的記憶體位置 | |
int main() { | |
int a, b;//宣告兩個整數 | |
printf("請輸入兩個數字(數字跟數字中間請以空白間隔)");//列印文字 | |
scanf("%d %d", &a, &b);//讓使用者輸入兩個數字 | |
printf("a:%d b:%d\n", a, b);//列印出變數 |
OlderNewer