第二次作業

2021-10-11 21:26:04 字數 1871 閱讀 6981

#include

#include

#include

using namespace std;

int main()

,, };//定義乙個隨機數組

for (int i = 0; i < 3; ++i)

cout << endl;

}

cout << endl;

if (x > y && x > z) //後三個if語句是用來比較每一行陣列之和,然後進行調換

cout << "wu xu diao huan";//此時無需調換

if (y > x && y > z)

cout << endl;

h = 0; ///每次都要讓h變為0值,否則進行下乙個for迴圈時,h的值不斷疊加

for (auto it = v2.begin(); it != v2.end(); ++it, ++h)

cout << endl;

h = 0;

for (auto it = v3.begin(); it != v3.end(); ++it, ++h)

}if (z > x && z > y)

cout << endl;

h = 0;

for (auto it = v2.begin(); it != v2.end(); ++it, ++h)

cout << endl;

h = 0;

for (auto it = v3.begin(); it != v3.end(); ++it, ++h)

}return 0;

第二道題

#include

#include

using namespace std;

int main()

}sum1 = 0;

for (n = 0,m=0; n =n; --i)

}for (i = 0,sum3=0; i < x; ++i)

sum2 = sum4 - sum1 + sum3;

cout << "上三角和:" << sum1 << endl;

cout << "下三角和:" << sum2 << endl;

cout << "主對角線和:" << sum3<< endl;

return 0;第三道題

#include

#include

using namespace std;

const int sz = 100;

int main()

else if ((carray[i] <= 90) && (carray[i] >= 65))

carray1 += carray[i];

}int len = carray1.size();

for (int i = 0; i < len / 2; i++)

}if (is_palindrome)

cout << "the string is a palindrome" << endl;

else

cout << "the string is not a palindrome" << endl;

return 0;第四題

#include

#include

using namespace std;

int main()

if (i >= n)

i = i % n;

while (vi[i] == 0)

if (vi[i] == 1)

vi[i] = 0;

}for (c = 0; c < n; ++c)

return 0;

}

第二次作業

execise02 1.查詢85年以後出生的學生姓名 性別和出生日期 2.列表顯示所有可能的學生選課組合 學號 課程號 3.查詢1 2 4班中陳姓同學的資訊 4.查詢所有及格的學生姓名 所選課程名及所得分數 5.統計各門課程的及格人數 課程編號 課程名 及格人數 6.統計各門課程的總人數 及格人數和...

第二次作業

第一題 p1 1 遞迴寫法,效率低 include 1.寫乙個函式返回引數值為1的個數 比如 15 0000 1111 4個1 程式原型 int count one bits unsigned int value int fuc int x else return 0 void mainp1 p1 ...

第二次作業

檔名稱 516.cpp 作 者 闕文榮 完成日期 2016 年 3 月 11 日 版 本 號 v1.1 對任務及求解方法的描述部分 用while語句控制輸出 輸入描述 略 問題描述 現在北京有一套房子,200萬,假設房價每年 10 乙個軟體工程師每年固定能賺40萬。他想買這套房子,多大的 率能夠忍受...