国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

C Primer Plus Test2

2019-08-24 10:47 作者:啷個(gè)里格朗郎郎  | 我要投稿

練習(xí)題來源:C Primer Plus(第6版)中文版

2.1

/**

編寫一個(gè)程序:

調(diào)用一次printf函數(shù),將名與姓打印在同一行,在調(diào)用一次,將名與姓分別打印在兩行,再調(diào)用兩次,將名與姓打印在一行。

Gustav Mahler
Gustav
Mahler
Gustav Mahler
*/
#include<stdio.h>
#include<stdlib.h>
int main(){

?? ?printf("Gustav Mahler\n");
?? ?printf("Gustav\nMahler\n");
?? ?printf("Gustav");
?? ?printf("Mahler\n");
?? ?system("pause");
?? ?return 0;

}

2.2

/*
?? ?將年齡轉(zhuǎn)換成天數(shù),并顯示出來,不考慮閏年問題
*/
#include<stdio.h>
#include<stdlib.h>
int main(){
?? ?
?? ?int age = 24;
?? ?int day;
?? ?day = age * 365;
?? ?printf("age = %d, day = %d\n", age, day);
?? ?system("pause");
?? ?return 0;
}

2.3

/*
?? ?編寫一個(gè)程序,生成以下輸出
?? ?For he's a jolly good fellow!
?? ?For he's a jolly good fellow!
?? ?For he's a jolly good fellow!
?? ?Which nobody can deny!
?? ?除main函數(shù)外,該程序還需定義兩個(gè)自定義函數(shù),一個(gè)名為jolly,調(diào)用一次打印一條
?? ?deny函數(shù),打印最后一條
*/
#include<stdio.h>
#include<stdlib.h>

void jolly(){
?? ?
?? ?printf("For he's a jolly good fellow!\n");
}

void deny(){
?? ?
?? ?printf("Which nobody can deny!\n");
}

int main(){
?? ?
?? ?jolly();
?? ?jolly();
?? ?jolly();
?? ?deny();
?? ?system("pause");
?? ?return 0;
}

2.4

/*
?? ?編寫一個(gè)程序,生成以下輸出
?? ?Brazil, Russia, India, China
?? ?Brazil, Russia
?? ?India, China
?? ?兩個(gè)自定義函數(shù),一個(gè)為br(),調(diào)用一次打印一次‘Brzail, Russia’;
?? ?另一個(gè)為ic(),調(diào)用一次打印一次‘India, China’
?? ?其他內(nèi)容在main函數(shù)中完成
*/
#include<stdio.h>
#include<stdlib.h>

void br(){
?? ?
?? ?printf("Brazil, Russia");
}

void ic(){
?? ?
?? ?printf("India, China");
}

int main(){
?? ?
?? ?br();
?? ?ic();
?? ?printf("\n");
?? ?br();
?? ?printf("\n");
?? ?ic();
?? ?printf("\n");
?? ?system("pause");
?? ?return 0;
}

2.5

/*
?? ?創(chuàng)建一個(gè)整型變量toes,并將oes設(shè)置為10,。
?? ?程序中還要計(jì)算toes的兩倍和平方,并將這三個(gè)值打印出來。
*/
#include<stdio.h>
#include<stdlib.h>
int main(){
?? ?
?? ?int toes = 10;
?? ?int toes_double, toes_sqirt;
?? ?toes_double = toes * 2;
?? ?toes_sqirt = toes * toes;
?? ?printf("toes = %d\ntoes_double = %d\ntoes_sqirt = %d\n", toes, toes_double, toes_sqirt);
?? ?system("pause");
?? ?return 0;
}

2.6

/*
?? ?生成以下格式的輸出
?? ?Smile!Smile!Smile!
?? ?Smile!Smile!
?? ?Smile!
?? ?定義一個(gè)函數(shù),該函數(shù)被調(diào)用一次打印一次Smile!,根據(jù)程序的需要使用該函數(shù)。
*/
#include<stdio.h>
#include<stdlib.h>

void Smile(){
?? ?
?? ?printf("Smile!");
}

int main(){
?? ?
?? ?int i;
?? ?int j;
?? ?
?? ?for( i = 0; i < 2; i++){
?? ??? ?for( j = i; j < 2; j ++){

?? ??? ??? ?Smile();
?? ??? ?}
?? ??? ?printf("\n");
?? ??? ?
?? ?}
?? ?
?? ?system("pause");
?? ?return 0;
}

2.7

/*
?? ?調(diào)用一個(gè)名為one_three()的函數(shù)。該函數(shù)在打印一行單詞one,在調(diào)用第二個(gè)函數(shù)two,
?? ?然后在另一行打印單詞three。two函數(shù)在一行顯示two,main函數(shù)在調(diào)用one_three函數(shù)前打印短語
?? ?starting now,并在調(diào)用完畢后顯示短語done!程序輸出如下
?? ?starting now:
?? ?one
?? ?two
?? ?three
?? ?done!
*/
#include<stdio.h>
#include<stdlib.h>

void two(){
?? ?
?? ?printf("two\n");
}

void one_three(){
?? ?
?? ?printf("one\n");
?? ?two();
?? ?printf("three\n");
}

int main(){
?? ?
?? ?printf("starting now:\n");
?? ?one_three();
?? ?printf("done!\n");
?? ?system("pause");
?? ?return 0;
}

C Primer Plus Test2的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
交城县| 侯马市| 修武县| 白玉县| 贵州省| 始兴县| 东平县| 葫芦岛市| 平舆县| 虎林市| 北京市| 泾阳县| 兴宁市| 溧水县| 库尔勒市| 宜兴市| 宣恩县| 新沂市| 沂南县| 苗栗市| 延津县| 承德县| 涟源市| 出国| 南开区| 芮城县| 兴山县| 两当县| 永嘉县| 哈尔滨市| 麻江县| 巨鹿县| 峡江县| 江川县| 井研县| 河西区| 中宁县| 琼中| 江都市| 栖霞市| 双峰县|