亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? selsolutionsc5.txt

?? c premier plus 課后習題答案
?? TXT
?? 第 1 頁 / 共 5 頁
字號:
   return 0;
} 

PE 11-13

/* Programming Exercise 11-13 */
#include <stdio.h>
#include <stdlib.h>        /* for atof()           */
#include <math.h>        /* for pow()            */
/* #include <console.h> */   /* Macintosh adjustment */
int main(int argc, char *argv[])
{
    double num, exp;
    
    /* argc = ccommand(&argv); */  /* Macintosh adjustment */  
    if (argc != 3)
        printf("Usage: %s number exponent\n", argv[0]);
    else
    {
        num = atof(argv[1]);
        exp = atof(argv[2]);
        printf("%f to the %f power = %g\n", num, exp, pow(num,exp));
    }
    
    return 0;
}

PE 11-15

/* Programming Exercise 11-15 */
#include <stdio.h>
#include <ctype.h>
/* #include <console.h> */   /* Macintosh adjustment */

int main(int argc, char *argv[])
{
    char mode = 'p';
    int ok = 1;
    int ch;
    
    /*argc = ccommand(&argv); */  /* Macintosh adjustment */  

    if (argc > 2)
    {
        printf("Usage: %s [-p | -u | -l]\n", argv[0]);
        ok = 0;                /* skip processing input */
    }
    else if (argc == 2)
    {
        if (argv[1][0] != '-')
        {
            printf("Usage: %s [-p | -u | -l]\n", argv[0]);
            ok = 0;
        }
        else 
            switch(argv[1][1])
            {
                case 'p' :
                case 'u' :
                case 'l' : mode = argv[1][1];
                           break;
                default  : printf("%s is an invalid flag; ", argv[1]);
                           printf("using default flag (-p).\n");
            }
    }
    
    if (ok)
        while ((ch = getchar() ) != EOF)
        {
            switch(mode)
            {
                case 'p'  :  putchar(ch);
                             break;
                case 'u'  :  putchar(toupper(ch));
                             break;
                case 'l'  :  putchar(tolower(ch));
            }
        }
                            
    return 0;
}

Chapter 12

PE 12-1

/* pe12-1.c  -- deglobalizing global.c */
/* Programming Exercise 12-1           */
/* one of several approaches */
#include <stdio.h>
void critic(int * u);
int main(void)
{
   int units;   /* units now local */

   printf("How many pounds to a firkin of butter?\n");
   scanf("%d", &units);
   while ( units != 56)
       critic(&units);
   printf("You must have looked it up!\n");
   return 0;
}

void critic(int * u)
{
   printf("No luck, chummy. Try again.\n");
   scanf("%d", u);
}

// or use a return value:
// units = critic(); 

// and have critic look like this:
/*
int critic(void)
{
   int u;
   printf("No luck, chummy. Try again.\n");
   scanf("%d", &u);
   return u;
}
*/

// or have main() collect the next value for units

PE 12-3

//pe12-3a.h

#define METRIC 0
#define US 1
#define USE_RECENT 2

void check_mode(int *pm);

void get_info(int mode, double * pd, double * pf);

void show_info(int mode, double distance, double fuel);

// pe12-3a.c
#include <stdio.h>
#include "pe12-3a.h"

void check_mode(int *pm)
{
    if (*pm != METRIC && *pm != US)
    {
        printf("Invalid mode specified. Mode %d\n", *pm);
        printf("Previous mode will be used.\n");
        *pm = USE_RECENT;
    }
}

void get_info(int mode, double * pd, double * pf)
{
    if (mode == METRIC)
        printf("Enter distance traveled in kilometers: ");
    else
        printf("Enter distance traveled in miles: ");
    scanf("%lf",pd);
    if (mode == METRIC)
        printf("Enter fuel consumed in liters: ");
    else
        printf("Enter fuel consumed  in gallons: ");
    scanf("%lf", pf);
}

void show_info(int mode, double distance, double fuel)
{
    printf("Fuel consumption is ");
    if (mode == METRIC)
        printf("%.2f liters per 100 km.\n", 100 * fuel / distance);
    else
        printf("%.1f miles per gallon.\n", distance / fuel);
}

// pe12-3.c
#include <stdio.h>
#include "pe12-3a.h"
int main(void)
{
  int mode;
  int prev_mode = METRIC;
  double distance, fuel;
  
  printf("Enter 0 for metric mode, 1 for US mode: ");
  scanf("%d", &mode);
  while (mode >= 0)
  {
        check_mode(&mode);
        if (mode == USE_RECENT)
            mode = prev_mode;
        prev_mode = mode;
      get_info(mode, &distance, &fuel);
      show_info(mode, distance, fuel);
        printf("Enter 0 for metric mode, 1 for US mode");
        printf(" (-1 to quit): ");
      scanf("%d", &mode);
  
  }
  printf("Done.\n");
  
  return 0;
}

PE 12-5

/* pe12-5.c  */
#include <stdio.h>
#include <stdlib.h>
void print(const int array[], int limit);
void sort(int array[], int limit);

#define SIZE 100
int main(void)
{
    int i;
    int arr[SIZE];
    
    for (i = 0; i < SIZE; i++)
        arr[i] = rand() % 10 + 1;
    puts("initial array");
    print(arr,SIZE);
    sort(arr,SIZE);
    puts("\nsorted array");
    print(arr,SIZE);
    
    return 0;
}

/* sort.c -- sorts an integer array in decreasing order */
void sort(int array[], int limit)
{
   int top, search, temp;

   for (top = 0; top < limit -1; top++)
       for (search = top + 1; search < limit; search++)
            if (array[search] > array[top])
            {
                 temp = array[search];
                 array[search] = array[top];
                 array[top] = temp;
            }
}

/* print.c -- prints an array */
void print(const int array[], int limit)
{
   int index;

   for (index = 0; index < limit; index++)
   {
      printf("%2d ", array[index]);
      if (index % 10 == 9)
         putchar('\n');
   }
   if (index % 10 != 0)
      putchar('\n');
}

PE 12-7

/* pe12-7.c  */
#include <stdio.h>
#include <stdlib.h>  /* for srand() */
#include <time.h>    /* for time()  */
int rollem(int);

int main(void)
{
    int dice, count, roll;
    int sides;
    int set, sets;
    
    srand((unsigned int) time(0));  /* randomize rand() */
    
    printf("Enter the number of sets; enter q to stop.\n");
    while ( scanf("%d", &sets) == 1)
    {
          printf("How many sides and how many dice?\n");
        scanf("%d %d", &sides, &dice);
        printf("Here are %d sets of %d %d-sided throws.\n", sets, dice,
                sides);
        for (set = 0; set < sets; set++)
        {
            for (roll = 0, count = 0; count < dice; count++)
                roll += rollem(sides);
                /* running total of dice pips */
            printf("%4d ", roll);
            if (set % 15 == 14)
                putchar('\n');
        }
        if (set % 15 != 0)
            putchar('\n');
        printf("How many sets? Enter q to stop.\n");
    }
    printf("GOOD FORTUNE TO YOU!\n");
    return 0;
}

int rollem(int sides)
{
    int roll;

    roll = rand() % sides + 1;
    return roll;
}

Chapter 13

PE 13-2

/* Programming Exercise 13-2 */
#include <stdio.h>
#include <stdlib.h>
//#include <console.h>    /* Macintosh adjustment */


int main(int argc, char *argv[])
{
    int byte;
    FILE * source;
    FILE * target;
    
//    argc = ccommand(&argv);   /* Macintosh adjustment */

    if (argc != 3)
    {
        printf("Usage: %s sourcefile targetfile\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    

    if ((source = fopen(argv[1], "rb")) == NULL)
    {
        printf("Could not open file %s for input\n", argv[1]);
        exit(EXIT_FAILURE);
    }
    if ((target = fopen(argv[2], "wb")) == NULL)
    {
        printf("Could not open file %s for output\n", argv[2]);
        exit(EXIT_FAILURE);
    }
    while ((byte = getc(source)) != EOF)
    {
        putc(byte, target);
    }
    if (fclose(source) != 0)
        printf("Could not close file %s\n", argv[1]);
    if (fclose(target) != 0)
        printf("Could not close file %s\n", argv[2]);
        
    return 0;
}

PE 13-4

/* Programming Exercise 13-4 */
#include <stdio.h>
#include <stdlib.h>
#include <console.h>    /* Macintosh adjustment */


int main(int argc, char *argv[])
{
    int byte;
    FILE * source;
    int filect;
    
    argc = ccommand(&argv);   /* Macintosh adjustment */  

    if (argc == 1)
    {
        printf("Usage: %s filename[s]\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    
    for (filect = 1; filect < argc; filect++)
    {
        if ((source = fopen(argv[filect], "r")) == NULL)
        {
            printf("Could not open file %s for input\n", argv[filect]);    
            continue;
        }
        while ((byte = getc(source)) != EOF)
        {
            putchar(byte);
        }
        if (fclose(source) != 0)
            printf("Could not close file %s\n", argv[1]);
    }    
        
    return 0;
}

PE 13-5

/* Programming Exercise 13-5 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <console.h>    /* Macintosh adjustment */

#define BUFSIZE 1024
#define SLEN 81
void append(FILE *source, FILE *dest);

int main(int argc, char *argv[])
{
    FILE *fa, *fs;
    int files = 0;
    int fct;
    
 //   argc = ccommand(&argv);   /* Macintosh adjustment */  

    if (argc < 3)
    {
        printf("Usage: %s appendfile sourcefile[s]\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    if ((fa = fopen(argv[1], "a")) == NULL)
    {
        fprintf(stderr, "Can't open %s\n", argv[1]);
        exit(EXIT_FAILURE);
    }
    if (setvbuf(fa, NULL, _IOFBF, BUFSIZE) != 0)
    {
        fputs("Can't create output buffer\n", stderr);
        exit(EXIT_FAILURE);
    }
    
    for (fct = 2; fct < argc; fct++)
    {
        if (strcmp(argv[fct], argv[1]) == 0)
            fputs("Can't append file to itself\n",stderr);
        else if ((fs = fopen(argv[fct], "r")) == NULL)
            fprintf(stderr, "Can't open %s\n", argv[fct]);
        else
        {
            if (setvbuf(fs, NULL, _IOFBF, BUFSIZE) != 0)
            {
                fputs("Can't create output buffer\n",stderr);
                continue;
            }
            append(fs, fa);
            if (ferror(fs) != 0)
                fprintf(stderr,"Error in reading file %s.\n",
                        argv[fct]);
            if (ferror(fa) != 0)
                fprintf(stderr,"Error in writing file %s.\n",
                        argv[1]);
            fclose(fs);
            files++;
            printf("File %s appended.\n", argv[fct]);
        }
    }
    printf("Done. %d files appended.\n", files);
    fclose(fa);

    return 0;
}

void append(FILE *source, FILE *dest)
{
    size_t bytes;
    static char temp[BUFSIZE]; // allocate once

    while ((bytes = fread(temp,sizeof(char),BUFSIZE,source)) > 0)
        fwrite(temp, sizeof (char), bytes, dest);
}

PE 13-7

/* Programming Exercise 13-7a */
/* code assumes that end-of-line immediately precedes end-of-file */

#include <stdio.h>
#include <stdlib.h>
#include <console.h>    /* Macintosh adjustment */

int main(int argc, char *argv[])
{
    int ch1, ch2;
    FILE * f1;
    FILE * f2;
    
    argc = ccommand(&argv);   /* Macintosh adjustment */  

    if (argc != 3)
    {
        printf("Usage: %s file1 file2\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    if ((f1 = fopen(argv[1], "r")) == NULL)
    {
        printf("Could not open file %s for input\n", argv[1]);    
        exit(EXIT_FAILURE);
    }
    if ((f2 = fopen(argv[2], "r")) == NULL)
    {
        printf("Could not open file %s for input\n", argv[2]);    
        exit(EXIT_FAILURE);
    }
    ch1 = getc(f1);
    ch2 = getc(f2);
    
    while (ch1 != EOF || ch2 != EOF)
    {
        while (ch1 != EOF && ch1 != '\n') /* skipped after EOF reached */
        {
            putchar(ch1);
            ch1 = getc(f1);
        }
        if (ch1 != EOF)
        {
            putchar('\n');
            ch1 = getc(f1);
        }
        while (ch2 != EOF && ch2 != '\n') /* skipped after EOF reached */
        {
            putchar(ch2);
            ch2 = getc(f2);
        }

        if (ch2 != EOF)
        {
            putchar('\n');
            ch2 = getc(f2);
        }
    }
        
    if (fclose(f1) != 0)
        printf("Could not close file %s\n", argv[1]);    
    if (fclose(f2) != 0)
        printf("Could not close file %s\n", argv[2]);    
        
    return 0;
}

/* Programming Exercise 13-7b */
/* code assumes that end-of-line immediately precedes end-of-file */

#include <stdio.h>
#include <stdlib.h>
#include <console.h>    /* Macintosh adjustment */

int main(int argc, char *argv[])
{
    int ch1, ch2;
    FILE * f1;
    FILE * f2;
    
    argc = ccommand(&argv);   /* Macintosh adjustment */  

    if (argc != 3)
    {
        printf("Usage: %s file1 file2\n", argv[0]);
        exit(EXIT_FAILURE);
    }
    if ((f1 = fopen(argv[1], "r")) == NULL)
    {
        printf("Could not open file %s for input\n", argv[1]);    
        exit(EXIT_FAILURE);
    }
    if ((f2 = fopen(argv[2], "r")) == NULL)
    {
        printf("Could not open file %s for input\n", argv[2]);    

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费电影视频| 欧美三级中文字幕| 一区二区三区资源| 99精品国产91久久久久久| 婷婷夜色潮精品综合在线| 精品国产乱码久久久久久闺蜜| 国产一区欧美日韩| 亚洲一区二区综合| 国产午夜亚洲精品不卡| 日韩一级片在线播放| 国产成人精品亚洲午夜麻豆| 在线精品观看国产| 最新国产成人在线观看| 蜜桃久久av一区| 国产精品乱码一区二三区小蝌蚪| 日韩一卡二卡三卡国产欧美| 国产精品嫩草久久久久| 欧美v日韩v国产v| 黄色小说综合网站| 26uuuu精品一区二区| 蜜臀a∨国产成人精品| 日本成人在线电影网| 成人性生交大片免费看视频在线| 在线视频观看一区| 欧美影院一区二区| 综合自拍亚洲综合图不卡区| 成人黄色综合网站| 国产精品麻豆欧美日韩ww| 国产主播一区二区三区| 欧美老年两性高潮| 亚洲手机成人高清视频| 国产成人夜色高潮福利影视| 国产精品青草综合久久久久99| 韩国成人精品a∨在线观看| 欧美影视一区二区三区| 国产成人三级在线观看| 亚洲电影一区二区| 国产亚洲欧美日韩俺去了| 色悠悠久久综合| 国产乱码精品1区2区3区| 亚洲人被黑人高潮完整版| 欧美人狂配大交3d怪物一区| 成人一级片网址| 精品无人码麻豆乱码1区2区| 亚洲永久免费av| 亚洲国产成人在线| 日韩一级二级三级| 日韩精品一区二区三区视频播放| 欧美日韩美女一区二区| 在线亚洲免费视频| 欧美日本韩国一区| 欧美日本精品一区二区三区| 午夜欧美电影在线观看| 在线免费精品视频| 美女性感视频久久| 亚洲高清三级视频| 一区二区三区国产精品| 亚洲三级在线免费观看| 亚洲国产经典视频| 国产精品免费观看视频| 国产精品蜜臀在线观看| 青青草视频一区| 欧美日韩国产精选| 亚洲高清视频中文字幕| 亚洲第一二三四区| 奇米影视一区二区三区小说| 激情丁香综合五月| yourporn久久国产精品| 欧美日韩亚洲综合| 精品美女在线观看| 国产精品网站在线观看| 亚洲福利视频一区| 国产在线精品免费| 一本久久a久久免费精品不卡| 这里是久久伊人| 中文字幕av一区 二区| 亚洲第一电影网| 国产成人综合亚洲网站| 91久久精品国产91性色tv| 日韩欧美的一区| 亚洲精品视频一区| 久久66热偷产精品| 色综合天天在线| 日韩精品一区二区三区四区| 亚洲天天做日日做天天谢日日欢 | 欧美日本免费一区二区三区| 精品国产一区二区三区久久影院| 亚洲色图视频网站| 老司机精品视频导航| 成人h动漫精品一区二区| 欧美色区777第一页| 欧美激情中文不卡| 日本在线观看不卡视频| 成人黄页毛片网站| 欧美成人精品福利| 亚洲国产精品久久人人爱蜜臀 | 国产成人精品影视| 欧美午夜精品理论片a级按摩| 欧美精品一区二区在线观看| 一区二区成人在线观看| 黑人巨大精品欧美黑白配亚洲| 一本大道av伊人久久综合| 26uuu精品一区二区在线观看| 亚洲一区二区三区三| 国产精品一区二区在线观看网站| 欧美日韩国产综合一区二区 | 亚洲一区二区av在线| 国产久卡久卡久卡久卡视频精品| 欧洲人成人精品| 国产精品午夜在线| 国产精品综合一区二区| 91精品国产乱码| 亚洲午夜久久久| 91成人在线免费观看| 最好看的中文字幕久久| 成人午夜av影视| 久久久www成人免费毛片麻豆| 婷婷开心久久网| 欧美午夜精品免费| 亚洲一二三区不卡| 在线看国产一区| 亚洲天堂精品在线观看| 成人av资源站| 国产欧美日韩不卡| 成人性生交大片免费看在线播放| 久久久蜜桃精品| 狠狠色丁香久久婷婷综| 2020日本不卡一区二区视频| 麻豆一区二区99久久久久| 日韩一区二区在线看| 婷婷综合另类小说色区| 欧美亚洲动漫制服丝袜| 亚洲国产va精品久久久不卡综合| 在线视频欧美精品| 亚洲一级二级三级| 欧美日韩精品二区第二页| 亚洲一区在线观看免费| 欧洲av在线精品| 亚洲午夜三级在线| 欧美日韩一区二区三区高清| 亚洲电影欧美电影有声小说| 欧美日韩在线电影| 日本aⅴ亚洲精品中文乱码| 欧美一区二区三区四区五区| 免费成人在线观看视频| 久久综合av免费| 成人一区二区三区| 中文字幕在线观看不卡| 91免费精品国自产拍在线不卡| 亚洲欧美日韩综合aⅴ视频| 在线视频中文字幕一区二区| 亚洲成a天堂v人片| 欧美一区二区在线视频| 精品一区二区三区的国产在线播放| 欧美精品一区二区久久久| 国产精品白丝jk黑袜喷水| 国产精品美女久久久久av爽李琼| 91丨九色丨黑人外教| 五月天欧美精品| 日韩美女主播在线视频一区二区三区| 久久99热99| 中文字幕精品三区| 91福利视频在线| 精品无人码麻豆乱码1区2区| 国产欧美日韩不卡| 欧美日精品一区视频| 久久97超碰色| 国产精品三级视频| 欧美性一二三区| 国产在线视视频有精品| 亚洲免费av观看| 日韩一级黄色片| 91在线视频免费91| 日韩精品一二区| 欧美国产日韩在线观看| 欧美亚洲自拍偷拍| 国产成人8x视频一区二区| 亚洲综合成人网| 久久婷婷成人综合色| 在线观看av一区| 国产精品123| 亚洲高清久久久| 日本一区免费视频| 在线播放91灌醉迷j高跟美女| 国产一区二区三区四| 一二三区精品福利视频| 久久伊人中文字幕| 欧美视频一二三区| 成人国产免费视频| 久久不见久久见免费视频1| 亚洲精品第一国产综合野| 精品国产乱码久久久久久免费| 92精品国产成人观看免费| 国产真实乱子伦精品视频| 亚洲成av人综合在线观看| 国产精品国产馆在线真实露脸| 欧美一级一区二区| 色哟哟亚洲精品| 国产成人8x视频一区二区| 美女网站在线免费欧美精品|