1、未經過處理的原始記錄。原始成績。輸入一個正整數N。如果N 除以2,其餘數為0。則其N為奇數。應該改為偶數 2022/8/628 010203040506070809101112Procedure Method()Begin int C_Score,E_Score,Average;C_Score=60;E_Score=70;Average=(C_Score+E_Score)/2;if(Average=60)printf(及格);else printf(不及格);End End Procedure i=2i+重複結構題目:陣列元素相加之演算法【解答】執行的次數01020304050607int s
2、um(int a,int n)int i,total=0;for(i=0;i n;i+)total+=ai;return total;1n+1n1T(P)=2n+3題目:兩矩陣a,b相加,利用雙重迴圈演算法【解答】執行的次數01020304050607void Add(int a,int b,int c,int n)int i,j;for(i=0;in;i+)for(j=0;jn;j+)ci,j=ai,j+bi,j;1n+1n*(n+1)n2T(P)=2n2+2n+2題目:兩矩陣a,ba,b相乘,利用多重迴圈演算法【解答】執行的次數010203040506070809101112void Mu
3、lti(int a,int b,int c,int n)int i,j,k,sum;for(i=0;i n;i+)for(j=0;j n;j+)sum=0;for(k=0;k n;k+)sum=sum+ai,k*bk,j;ci,j=sum;1n+1n*(n+1)n2n2*(n+1)n3n2T(P)=2n3+4 4n2+2n+2演算法For i=1 to n do For j=i to n do x=x+1 End End 演算法統計執行的次數For i=1 to n do For j=i to n do x=x+1 End End i=1 i=2 i=3 i=nj=1 to n j=2 to n j=3 to n j=n to n執行:n次 (n-1)次 (n-2)次 1次次項數尾項首項2)1(2)(nn2n+3=O(n)2n2+2n+2=O(n2)2n3+4n2+2n+2=O(n3)O(log2 n)O(n)O(n log2 n)O(n2)O(n3)O(2n)O(n!)