亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

急急急!快考試了!求大佬解答!

https://img1.sycdn.imooc.com//5b41ca22000133bb10801920.jpg

https://img1.sycdn.imooc.com//5b41ca240001122510801920.jpg

https://img1.sycdn.imooc.com//5b41ca2700019eaf10801920.jpg

https://img1.sycdn.imooc.com//5b41ca2800017f2d10801920.jpg

求各位大哥看看!急急急!


正在回答

4 回答

實驗4

#include<iostream>
using namespace std;
int main()
{
?float n,i,sum=0;//定義原始數據
?cout << "請輸入n:";
?cin >> n;
?if (n < 10)//滿足n>=10的條件
??cout << "請輸入不小于10的數" << endl;
?else
?{
??for (i = 1; i <= n; i++)//計算過程
???sum +=( i / ((2 * i - 1)*(2 * i + 1)));
??cout << "計算結果為:";//顯示結果
??cout << sum << endl;
?}
?system("pause");
?return 0;
}

2 回復 有任何疑惑可以回復我~

實驗3

#include<iostream>
using namespace std;
void sfun(char s1[],char s2[])
{
?int i,j;
?for (i = 0, j = 0; i <= 99; i++)//通過ASCII碼判斷數組元素是否為數字
?{
??if (s1[i] >= 48 && s1[i] <= 57)
??{
???s2[j] = s1[i];
???j++;
??}
?}
?cout << "輸出s2數組為:" << s2 << endl;//輸出s2數組

}
int main()
{
?static char s1[100], s2[100];
?cout << "請輸入s1數組:";//構建s1數組
?cin >> s1;
?sfun(s1, s2);
?system("pause");
?return 0;
}


0 回復 有任何疑惑可以回復我~

實驗2

#include<iostream>
using namespace std;
int fact(int n)
{
?static int arr[50];
?int i,j,max;
?for (i = 1,j=0; i < n; i++)//計算并記錄輸入的數的因子
?{
??if (n%i == 0)
??{
???arr[j] = i;
???j++;
??}
?}
?max = arr[0];//初始化最大值
?for (j = 0; j <=? 49,arr[j]!=0; j++)//計算最大因子
?{
??if (arr[j] > max)
???max = arr[j];
?}
?return max;//返回最大因子
}
int main()
{
?int n;
?cout << "請輸入所要計算最大因子的數:";
?cin >> n;
?cout << "該數最大因子為:";
?cout << fact(n) << endl;;
?system("pause");
?return 0;
}

0 回復 有任何疑惑可以回復我~

也許你已經考完了,我還是用C++寫了下,祝你考試不掛科

所發順序按你的圖片順序來,菜雞編的程序,輕噴

#include<iostream>
using namespace std;
int main()
{
?int str[5][5];
?int i,j,sum=0;
?cout << "請輸入數組內容:" << endl;//創建數組內容
?for (i = 0; i <= 4; i++)
?{
??for (j = 0; j <= 4; j++)
???cin >> str[i][j];
?}
?cout << "輸出數組結果為:" << endl;//輸出數組內容
?for (i = 0; i <= 4; i++)
?{
??for (j = 0; j <= 4; j++)
???cout << str[i][j] << " ";
??cout << endl;
?}
?for (i = 1; i <= 4; i++)//計算數組偶數行元素和
?{
??if (i % 2 == 1)
??{
???for (j = 0; j <= 4; j++)
????sum += str[i][j];
??}
?}
?cout << "所有偶數行元素和為:" << sum << endl;
?system("pause");//為了能夠查看程序運行結果所加的語句,可忽略
?return 0;
}

這個程序為了方便檢查運行就沒用10×10的數組,用了5×5的,改改數字就行了

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

急急急!快考試了!求大佬解答!

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號