假定已經有許多應用采用了程序1 - 1 5中所定義的C u r r e n c y類,現在我們想要對C u r r e n c y類
的描述進行修改,使其應用頻率最高的兩個函數A d d和I n c r e m e n t可以運行得更快,從而提高應
用程序的執行速度。由于用戶僅能通過p u b l i c部分所提供的接口與C u r r e n c y類進行交互,
溫度華氏轉變攝氏
#include <stdio.h>
#include <stdlib.h>
enum x {A,B,C,D,E}
int main(void)
{
int a=73,b=85,c=66
{
if (a>=90)
printf("a=A等級!!\n")
else if (a>=80)
printf("73分=B等級!!\n")
else if (a>=70)
printf("73分=C等級!!\n")
else if (a>=60)
printf("73分=D等級!!\n")
else if (a<60)
printf("73分=E等級!!\n")
}
{
if (b>=90)
printf("b=A等級!!\n")
else if (b>=80)
printf("85分=B等級!!\n")
else if (b>=70)
printf("85分=C等級!!\n")
else if (b>=60)
printf("85分=D等級!!\n")
else if (b<60)
printf("85分=E等級!!\n")
}
{
if (c>=90)
printf("c=A等級!!\n")
else if (c>=80)
printf("66分=B等級!!\n")
else if (c>=70)
printf("66分=C等級!!\n")
else if (c>=60)
printf("66分=D等級!!\n")
else if (c<60)
printf("66分=E等級!!\n")
}
system("pause")
return 0
}
溫度華氏轉變攝氏
#include <stdio.h>
#include <stdlib.h>
enum x {A,B,C,D,E}
int main(void)
{
int a=73,b=85,c=66
{
if (a>=90)
printf("a=A等級!!\n")
else if (a>=80)
printf("73分=B等級!!\n")
else if (a>=70)
printf("73分=C等級!!\n")
else if (a>=60)
printf("73分=D等級!!\n")
else if (a<60)
printf("73分=E等級!!\n")
}
{
if (b>=90)
printf("b=A等級!!\n")
else if (b>=80)
printf("85分=B等級!!\n")
else if (b>=70)
printf("85分=C等級!!\n")
else if (b>=60)
printf("85分=D等級!!\n")
else if (b<60)
printf("85分=E等級!!\n")
}
{
if (c>=90)
printf("c=A等級!!\n")
else if (c>=80)
printf("66分=B等級!!\n")
else if (c>=70)
printf("66分=C等級!!\n")
else if (c>=60)
printf("66分=D等級!!\n")
else if (c<60)
printf("66分=E等級!!\n")
}
system("pause")
return 0
}
Data Structures and Algorithms
with Object-Oriented Design Patterns in Java
Bruno R. Preiss
B.A.Sc., M.A.Sc., Ph.D., P.Eng.
Associate Professor
Department of Electrical and Computer Engineering
University of Waterloo, Waterloo, Canada
learningMatlab
PhÇ n 1
c¬ së Mat lab
Ch ¬ ng 1:
Cµ i ® Æ t matlab
1.1.Cµ i ® Æ t ch ¬ ng tr×nh:
Qui tr×nh cµ i ® Æ t Matlab còng t ¬ ng tù nh viÖ c cµ i ® Æ t c¸ c ch ¬ ng tr×nh phÇ n mÒ m kh¸ c, chØ cÇ n theo c¸ c h íng dÉ n vµ bæ xung thª m c¸ c th« ng sè cho phï hî p.
1.1.1 Khë i ® éng windows.
1.1.2 Do ch ¬ ng tr×nh ® î c cÊ u h×nh theo Autorun nª n khi g¾ n dÜ a CD vµ o æ ® Ü a th× ch ¬ ng tr×nh tù ho¹ t ® éng, cö a sæ
metricmatlab
ch ¬ ng 4
Ma trË n - c¸ c phÐ p to¸ n vÒ ma trË n.
4.1 Kh¸ i niÖ m:
- Trong MATLAB d÷ liÖ u ® Ó ® a vµ o xö lý d íi d¹ ng ma trË n.
- Ma trË n A cã n hµ ng, m cét ® î c gä i lµ ma trË n cì n m. § î c ký hiÖ u An m
- PhÇ n tö aij cñ a ma trË n An m lµ phÇ n tö n» m ë hµ ng thø i, cét j .
- Ma trË n ® ¬ n ( sè ® ¬ n lÎ ) lµ ma trË n 1 hµ ng 1 cét.
- Ma trË n hµ ng ( 1 m ) sè liÖ u ® î c bè trÝ trª n mét hµ ng.
a11 a12 a13 ... a1m
- Ma trË n cét ( n 1) sè liÖ u ® î c bè trÝ trª n 1 cét.
We have a group of N items (represented by integers from 1 to N), and we know that there is some total order defined for these items. You may assume that no two elements will be equal (for all a, b: a<b or b<a). However, it is expensive to compare two items. Your task is to make a number of comparisons, and then output the sorted order. The cost of determining if a < b is given by the bth integer of element a of costs (space delimited), which is the same as the ath integer of element b. Naturally, you will be judged on the total cost of the comparisons you make before outputting the sorted order. If your order is incorrect, you will receive a 0. Otherwise, your score will be opt/cost, where opt is the best cost anyone has achieved and cost is the total cost of the comparisons you make (so your score for a test case will be between 0 and 1). Your score for the problem will simply be the sum of your scores for the individual test cases.