最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

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

小白學(xué)編程7:代碼復(fù)用,理解函數(shù)

2023-08-02 11:48 作者:盛格塾  | 我要投稿

《小白學(xué)編程》第七講的相關(guān)代碼:

#include <stdio.h>


int gd_square(int x)

{

??return x*x;

}


int main()

{

??int n = 88;

??printf("square of %d is %d\n", n, gd_square(n));


??return 0;

}

~


#include <stdio.h>


int main(int argc, const char* argv[])

{

??printf("main received %d arguments\n", argc);


??for(int i = 0; i < argc; i++) {

????printf("argv[%d] = %s\n", i, argv[i]);

??}


??return 0;

}





#include <stdio.h>


int usage()

{

??printf("gdplay %d.%d, a utility just for fun\n"

??????"\tgdplay [options]\n"

??????"\t supported options:\n"

??????"\t -h show this help\n"

??????"\t -t print time\n", VER_MAJOR, VER_MINOR);

}

void gd_time()

{

}


int main(int argc, const char* argv[])

{

??printf("main received %d arguments\n", argc);


??for(int i = 0; i < argc; i++) {

????printf("argv[%d] = %s\n", i, argv[i]);

??}


??if(argc <= 1)

????return usage();


??if(argv[1][0] == '-') {

????switch(argv[1][1]) {

??????case?'h':

????????return usage();

??????case?'t':

????????gd_time();

????????break;

????}

??}

??return 0;

}




#define VER_MAJOR 0

#define VER_MINOR 1



geduer@gdk8:~/clabs$ cat lab5-3.c

#include <stdio.h>

#include <time.h>


#define VER_MAJOR 0

#define VER_MINOR 1


int usage(const char* msg)

{

??if(msg != NULL) {

??????printf("error: %s\n", msg);

??}


??printf("gdplay %d.%d, a utility just for fun\n"

??????"syntax: gdplay [options]\n"

??????"\tsupported options:\n"

??????"\t-h show this help\n"

??????"\t-t print time\n", VER_MAJOR, VER_MINOR);

}

void gd_time()

{

??time_t now;

??struct tm* tminfo;

??char buffer[80];


??time(&now);

??tminfo = localtime(&now);

??strftime(buffer, sizeof(buffer), "%F %h %H:%M:%S %p %c", tminfo);

??puts(buffer);

}


int main(int argc, const char* argv[])

{

??printf("main received %d arguments\n", argc);


??for(int i = 0; i < argc; i++) {

????printf("argv[%d] = %s\n", i, argv[i]);

??}


??if(argc <= 1)

????return usage("missing arguments");


??if(argv[1][0] == '-') {

????switch(argv[1][1]) {

??????case?'h':

????????return usage(NULL);

??????case?'t':

????????gd_time();

????????break;

????}

??}

??return 0;

}

小白學(xué)編程7:代碼復(fù)用,理解函數(shù)的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
永州市| 洛川县| 防城港市| 阜南县| 沁阳市| 应城市| 咸丰县| 谷城县| 邢台市| 博野县| 永年县| 汉沽区| 车致| 山阳县| 渝北区| 雅安市| 玉山县| 卓尼县| 清徐县| 黔西县| 略阳县| 上蔡县| 花莲县| 桂东县| 海丰县| 卫辉市| 富源县| 镇安县| 沾化县| 思茅市| 启东市| 长岭县| 塔河县| 呼和浩特市| 青田县| 禹城市| 萝北县| 峨边| 巴南区| 北京市| 马龙县|