欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

復(fù)習(xí)回顧c語(yǔ)言刷題Day01-創(chuàng)新互聯(lián)

n的階乘

#include

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了吉林免費(fèi)建站歡迎大家使用!

using namespace std;

int fact (int n){
?int res = 1;
?for(int i = 1; i<= n; i++){
??? ?res *= i;
?}
?return res;
}

int main(){
?int n;
?cin >>n;
?
?cout<< fact(n)<< endl;
?
?return 0;
}

x和y的大值

#include

using namespace std;

int max (int x, int y){
?if(x >y)return x;
?else return y;
}

int main(){
?int x, y;
?cin >>x >>y;
?
?cout<< max(x, y)<< endl;
?
?return 0;
}

求解a和b的大公約數(shù)

#include

using namespace std;

int gcd (int a, int b){
?for(int i =1000; i; i-- ){
??? ?if(a % i == 0 && b % i == 0 )
??? ?return i;
??? ?}
??? ?return 0;
?}

int main(){
?int a, b;
?cin >>a >>b;
?
?cout<< gcd(a, b)<< endl;
?
?return 0;
}

交換a和b的值

#include

using namespace std;

void swap(int &x, int &y){
?if(x == y)return ;
?int t = x;
?x = y;
?y = t;
}
int main(){
?int x, y;
?cin >>x >>y;
?
?swap(x, y);
?
?cout<< x<< " "<< y<< endl;
?
?return 0;
}

打印數(shù)字

輸入一個(gè)長(zhǎng)度為?n?的數(shù)組?a?和一個(gè)整數(shù)?size,請(qǐng)你編寫一個(gè)函數(shù),?void print(int a[], int size), 打印數(shù)組?a?中的前?size?個(gè)數(shù)。

輸入格式

第一行包含兩個(gè)整數(shù)?n和?size。

第二行包含?n?個(gè)整數(shù)?a[i],表示整個(gè)數(shù)組。

輸出格式

共一行,包含?size個(gè)整數(shù),表示數(shù)組的前?size個(gè)數(shù)。

數(shù)據(jù)范圍

1≤n≤1000
1≤size≤n

#include

using namespace std;

const int N = 1000;

void print(int a[], int size){
?for(int i = 0; i< size; i++){
??? ?cout<< a[i]<< " " ;
?}
?cout<< endl;
}
int main(){
?int n, size;
?int a[N];
?
?cin >>n >>size;
?
?for(int i = 0; i< n; i++)cin >>a[i];?
?
?print(a, size);
?
?return 0;
}

打印矩陣

#include

using namespace std;

void print2D(int a[][100], int row, int col){
?for(int i = 0; i< row; i++){
??? ?for(int j = 0 ; j< col; j++){
??? ??? ?cout<< a[i][j]<< " ";
??? ?}
??? ?cout<< endl;
?}
}
int main(){
?int row, col;
?
?int a[100][100];
?
?cin >>row >>col;
?for(int i = 0; i< row; i++){
??? ?for(int j = 0; j< col; j++){
??? ??? ?cin >>a[i][j];
??? ?}
?}?
?print2D(a, row, col);
?
?return 0;
}

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級(jí)服務(wù)器適合批量采購(gòu),新人活動(dòng)首月15元起,快前往官網(wǎng)查看詳情吧

網(wǎng)頁(yè)名稱:復(fù)習(xí)回顧c語(yǔ)言刷題Day01-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)網(wǎng)址:http://www.chinadenli.net/article4/didcie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序定制開(kāi)發(fā)網(wǎng)站建設(shè)網(wǎng)頁(yè)設(shè)計(jì)公司電子商務(wù)網(wǎng)站排名

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名