C語言 實驗8

2021-10-09 12:10:39 字數 2695 閱讀 3258

一、192頁10.1

#include

#include

void

exchange

(int

*min,

int*max)

;int

main

(void

) q=

(int*)

malloc

(sizeof

(int))

;if(q==

null

)printf

("輸入第乙個數:");

scanf

("%d"

,p);

printf

("輸入第二個數:");

scanf

("%d"

,q);if(

*p>

*q)printf

("小值為%d,大值為%d。\n"

,*p,

*q);

free

(p);

free

(q);

return0;

}void

exchange

(int

*min,

int*max)

#include

#include

void

exchange

(int

*min,

int*max)

;int

main

(void

) q=

(int*)

malloc

(sizeof

(int))

;if(q==

null

)printf

("輸入第乙個數:");

scanf

("%d"

,p);

printf

("輸入第二個數:");

scanf

("%d"

,q);if(

*p>

*q)printf

("小值為%d,大值為%d。\n"

,*p,

*q);

free

(p);

free

(q);

return0;

}void

exchange

(int

*min,

int*max)

二、193頁10.2

#include

void

datetoyearday

(int year,

int month,

int day,

int*pyearday)

;void

yeardaytodate

(int year,

int yearday,

int*pmonth,

int*pday)

;int

main()

else

printf

("輸入年份值和第幾天:");

scanf

("%d%d"

,&year,

&days)

;yeardaytodate

(year,days,

&month,

&day);if

(month==-1

)else

return0;

}void

datetoyearday

(int year,

int month,

int day,

int*pyearday)

;*pyearday=0;

if(year<=0)

if(year%4==

0&&year%

100!=

0||year%

400==0)

if(month>=

1&&month<=12)

}else

if(day<

1||day>months[month-1]

)*pyearday+

=day;

}void

yeardaytodate

(int year,

int yearday,

int*pmonth,

int*pday);if

(year<=0)

if(year%4==

0&&year%

10!=

0||year%

400==0)

}else

}for

(i=0

;yearday>

0;i++

)*pmonth=i;

*pday=yearday+months[i-1]

;}

三、193頁10.3

#include

intmain

(void);

printf

("輸入數字月份:");

scanf

("%d"

,&month);if

(month<

1||month>12)

else

return0;

}

《組合語言》實驗8

分析下面的程式,在執行前思考 這個程式可以正確返回嗎?執行後再思考 為什麼是這種結果?assume cs codesg codesg segment mov ax,4c00h int21hstart mov ax,0s nopnop mov di,offset s mov si,offset s2 ...

C語言實驗 排列

c語言實驗 排列 time limit 1000ms memory limit 65536kb problem description 有4個互不相同的數字,請按序輸出由其中三個不重複數字組成的排列。input 4個整數。output 所有排列,輸出順序見樣例。example input 1 2 3...

C語言 實驗整理

實驗二 陣列操作 實驗三 呼叫函式 實驗四 指標,處理字串 課程設計 銷售業績管理系統 感想 題目求1 1 2 1 3 1 4 1 99 1 100之值。求出200到300之間的數,且滿足條件 它們三個數字之積為42 三個數字之和為12。一 include intmain printf f sum ...