??xml version="1.0" encoding="utf-8" standalone="yes"?>99精品综合,成人a级免费视频,亚洲欧美日本国产http://www.aygfsteel.com/BeautifulMan/zh-cnWed, 18 Jun 2025 06:27:19 GMTWed, 18 Jun 2025 06:27:19 GMT60C Primer Plus W?5?位操?复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2016/01/06/428948.html李阿昀李阿昀Wed, 06 Jan 2016 01:27:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2016/01/06/428948.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428948.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2016/01/06/428948.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428948.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428948.html阅读全文

李阿昀 2016-01-06 09:27 发表评论
]]>
《汇~语aQ第3版)?实验4 [bx]和loop的?/title><link>http://www.aygfsteel.com/BeautifulMan/archive/2015/12/15/428652.html</link><dc:creator>李阿昀</dc:creator><author>李阿昀</author><pubDate>Tue, 15 Dec 2015 01:06:00 GMT</pubDate><guid>http://www.aygfsteel.com/BeautifulMan/archive/2015/12/15/428652.html</guid><wfw:comment>http://www.aygfsteel.com/BeautifulMan/comments/428652.html</wfw:comment><comments>http://www.aygfsteel.com/BeautifulMan/archive/2015/12/15/428652.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428652.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/BeautifulMan/services/trackbacks/428652.html</trackback:ping><description><![CDATA[q是王爽老师的《汇~语aQ第3版)》,l知友推荐确实是一本极好的书!<br /><br /><div>实验4 [bx]和loop的?/div>Q?Q、(2Q?br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->assume cs:code<br />code segment<br />    mov ax,0020h<br />    mov ds,ax<br />    mov bx,0<br />    mov cx,64<br />  s:mov [bx],bl   ;q里必须是mov [bx],blQ而不能是mov [bx],bx,否则?x)出现类型不匚w<br />    inc bl<br />    loop s<br />    mov ax,4c00h<br />    <span style="color: #0000FF; ">int</span> 21h<br />code ends<br />end</div><br /><br /><br /><br /><br /><br /><br /><br /><br /><img src ="http://www.aygfsteel.com/BeautifulMan/aggbug/428652.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/BeautifulMan/" target="_blank">李阿昀</a> 2015-12-15 09:06 <a href="http://www.aygfsteel.com/BeautifulMan/archive/2015/12/15/428652.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C Primer Plus W?4?l构和其他数据Ş?复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2015/12/10/428593.html李阿昀李阿昀Thu, 10 Dec 2015 08:53:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2015/12/10/428593.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428593.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2015/12/10/428593.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428593.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428593.htmlstructure {    char itable;    int&nb...  阅读全文

李阿昀 2015-12-10 16:53 发表评论
]]>
C Primer Plus W?3?文g输入/输出 复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2015/12/07/428533.html李阿昀李阿昀Mon, 07 Dec 2015 04:02:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2015/12/07/428533.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428533.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2015/12/07/428533.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428533.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428533.html/* 把多个文件的内容q加C个文件中 */#include <stdio.h>#include &...  阅读全文

李阿昀 2015-12-07 12:02 发表评论
]]>
C Primer Plus W?2?存储cR链接和内存理 复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2015/12/04/428522.html李阿昀李阿昀Fri, 04 Dec 2015 12:03:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2015/12/04/428522.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428522.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2015/12/04/428522.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428522.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428522.html阅读全文

李阿昀 2015-12-04 20:03 发表评论
]]>
C Primer Plus W?1?字符串和字符串函?复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2015/11/30/428413.html李阿昀李阿昀Mon, 30 Nov 2015 01:47:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/30/428413.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428413.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/30/428413.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428413.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428413.html阅读全文

李阿昀 2015-11-30 09:47 发表评论
]]>
C Primer Plus W?0?数组和指?复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2015/11/24/428353.html李阿昀李阿昀Tue, 24 Nov 2015 14:31:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/24/428353.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428353.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/24/428353.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428353.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428353.html// 多维数组和指?include <stdio.h>int main(void){  ...  阅读全文

李阿昀 2015-11-24 22:31 发表评论
]]>
C Primer Plus W??函数 复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2015/11/22/428322.html李阿昀李阿昀Sun, 22 Nov 2015 15:03:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/22/428322.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428322.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/22/428322.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428322.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428322.html扩展L(fng)步编E练?Q?/span>
#include <stdio.h>
void to_binary(unsigned long n);
int main(void)
{
    unsigned long number;
    printf("Enter an integer (q to quit): \n");
    while(scanf("%lu", &number) == 1)
    {
        printf("Binary equivalent: ");
        to_binary(number);
        putchar('\n');
        printf("Enter an integer (q to quit): \n");
    }
    printf("Done!\n");
    return 0;
}
void to_binary(unsigned long n)
{
    int r;
    r = n % 2;
    if(n >= 2)
        to_binary(n / 2);
    putchar('0' + r);
    return;
}
复习(fn)?/span>
1、实际参数和形式参量有何不同Q?br />{:(x)
形式参量Q也被称为Ş式参敎ͼ是一个变量,它在被调函数中进行定义。实际参数是在函数调用中出现的|它被赋值给形式参量。可以把实际参数认ؓ(f)是在函数被调用时用来初始化Ş式参量的倹{?br />2、写Z面所描述的各个函数的ANSI函数头。注意:(x)只写出函数头卛_Q不需要实现?br />a.donut()接受一个intcd的参敎ͼ然后输出若干?Q输?的数目等于参数的倹{?br />b.gear()接受两个intcd的参数ƈq回intcd的倹{?br />c.stuff_it()的参数包括一个doublecd的g及一个doublecd变量的地址Q功能是把第一个数值存攑ֈ指定的地址中?br />{:(x)
a.void donut(int n)
b.int gear(int n, int m)
c.void stuff_it(double n, double * d)
3、只写出下列函数的ANSI C函数_(d)不需要实现函数?br />a.n_to_char()接受一个intcd的参数ƈq回一个charcd的倹{?br />b.digits()接受的参数是一个doublecd的数值和一个intcd的数|q回值类型是int?br />c.random()不接受参敎ͼq回intcd的数倹{?br />{:(x)
a.char n_to_char(int n)
b.int digits(double n, int m)
c.int random(void)
4、设计一个实C整数相加q将l果q回的函数?br />{:(x)
int plus(int n, int m)
{
    return n + m;
}
5、假如问?中的函数实现两个doublecd的数值相加,那么应该如何修改原函敎ͼ
{:(x)
double plus(double n, double m)
{
    return n + m;
}
6、设计函数alter()Q其输入参数是两个intcd的变量x和yQ功能是分别这两个变量的数值改为它们的和以及它们的差?br />{:(x)Q?span style="background-color: yellow;">注意Q下面这U写法是错误的!Q!Q?/span>
void alter(int x, int y)
{
    x = x + y;
    y = x - y;
}
正确的写法如下:(x)
void alter(int * u, int * v)
{
    int temp;

    temp = *u;
    *u = *u + *v;
    *v = temp - *v;
}
7、判断下面的函数定义是否正确?br />
void salami(num)
{
    int num, count;

    for(count = 1; count <= num; num++)
        printf("O salami mio!\n");
}
{:(x)
有错误。num应该在salami()的参数列表中而不是在花括号之后声明,而且应该是count++而不是num++?br />8、编写一个函敎ͼ使其q回3个整数参C的最大倹{?br />{:(x)
int max(int x, int y, int z)
{
    int max;
    if(x > y)
        if(x > z)
            max = x;
        else
            max = z;
    else
        if(y > z)
            max = y;
        else
            max = z;
    return max;
}
or Q?span style="background-color: yellow;">更简z一点)

int max(int x, int y, int z)
{
    int max = x;
    if(y > max)
        max = y;
    if(z > max)
        max = z;
    return max;
}
9、给定下面的输出Q?br />Please choose one of the following:
1)copy files 2)move files
3)remove files 4)quit
Enter the number of your choice:
a.用一个函数实现菜单的昄Q且该菜单有4个用数字~号的选项q要求你选择其中之一Q输出应该如题中所C)?br />b.~写一个函敎ͼ该函数接受两个intcd的参敎ͼ(x)一个上界和一个下界。在函数中,首先从输入终端读取一个整敎ͼ如果该整C在上下界规定的范围内Q则函数重新昄菜单Q用本题目a(chn)部分中的函数Q以再次提醒用户输入新倹{如果输入数值在规定的范围内Q那么函数应该将数D回给调用函数?br />c.使用本题目a(chn)和b部分中的函数~写一个最的E序。最的意思是该程序不需要实现菜单中所描述的功能;它只需要显C些选项q能获取正确的响应即可?br />{:(x)Q参考课后答案)
#include <stdio.h>
void menu(void);
int get_input(intint);
int main(void)
{
    int res;

    menu();
    while((res = get_input(1, 4)) != 4)
        printf("I like choice %d.\n", res);
    printf("Bye!\n");
    return 0;
}
void menu(void)
{
    printf("Please choose one of the following: \n");
    printf("1)copy files          2)move files\n");
    printf("3)remove files        4)quit\n");
    printf("Enter the number of your choice: \n");
}
int get_input(int min, int max)
{
    int number;

    scanf("%d", &number);
    while(number < min || number > max)
    {
        printf("%d is not a valid choice; try again.\n", number);
        menu();
        scanf("%d", &number);
    }
    return number;
}
~程l习(fn)
1?br />
#include <stdio.h>
double min(doubledouble);
int main(void)
{
    printf("One of the smaller of the two numbers is %.2f", min(23.34, 12.11));
    return 0;
}
double min(double x, double y)
{
    return x < y ? x : y;
}
2?br />
#include <stdio.h>
void chline(char ch, int i, int j);
int main(void)
{
    chline('$', 3, 5);
    return 0;
}
void chline(char ch, int i, int j)
{
    int index;

    for(index = 1; index < i; index++)
        putchar(' ');
    for(index = 1; index <= j - i + 1; index++)
        putchar(ch);
}
3?br />
#include <stdio.h>
void chline(char ch, int col, int row);
int main(void)
{
    chline('$', 3, 5);
    return 0;
}
void chline(char ch, int col, int row)
{
    int i, j;

    for(i = 0; i < row; i++)
    {
        for(j = 0; j < col; j++)
           putchar(ch);
        putchar('\n');
    }
}
4?br />
#include <stdio.h>
double computer(double a, double b);
int main(void)
{
    printf("%.2f?.2f的谐均值是Q?.3f\n", 0.3, 0.5, computer(0.3, 0.5));
    return 0;
}
double computer(double a, double b)
{
    double result;

    result = 1 / ((1/a + 1/b) / 2);
    return result;
}
5?br />
#include <stdio.h>
void larger_of(double *, double *);
int main(void)
{
    double x = 23.3;
    double y = 34.4;
    printf("Originally x = %.1f; y = %.1f\n", x, y);
    larger_of(&x, &y);
    printf("Now x = %.1f; y = %.1f\n", x, y);
    return 0;
}
void larger_of(double * u, double * v)
{
    double temp;
    temp = *u > *v ? *u : *v;
    *u = temp;
    *v = temp;
}
6、(W一ơ码的程序读取到换行W的时候也?x)打印出来,会(x)给人看不明白的感觉Q烦性按[Enter]键的时候就退出@环,不要dEOFQ?br />
#include <stdio.h>
#include <ctype.h>
void printchar(char ch);
int main(void)
{
    char ch;

    printf("误入要分析的东西:(x)\n");
    while((ch = getchar()) != EOF)
    {
        printchar(ch);
    }
    return 0;
}
void printchar(char ch)
{
    if(isalpha(ch))
    {
        printf("%c %d\n", ch, toupper(ch) % 'A' + 1);
    }
}
修改之后Q程序如下:(x)
#include <stdio.h>
#include <ctype.h>
int show_c_location(char ch);

int main(void)
{
    char ch;

    printf("Please enter some characters: \n");
    while((ch = getchar()) != '\n')
        printf("%c-%d ", ch, show_c_location(ch));
    return 0;
}
int show_c_location(char ch)
{
    int result;

    if(isalpha(ch))
        result = toupper(ch) - 'A' + 1;
    else
        result = -1;
    return result;
}
7?br />
#include <stdio.h>
double power(double n, int p);
int main(void)
{
    double x, xpow;
    int exp;

    printf("Enter a number and the positive integer power");
    printf(" to which\nthe number will be raised. Enter q");
    printf(" to quit.\n");
    while(scanf("%lf%d", &x, &exp) == 2)
    {
        xpow = power(x, exp);
        printf("%.3g to power %d is %.5g\n", x, exp, xpow);
        printf("Enter next pair of numbers or q to quit.\n");
    }
    printf("Hope you enjoyed this power trip -- bye!\n");
    return 0;
}
double power(double n, int p)
{
    int i;
    double result = 1;

    if(n != 0)
    {
        if(p > 0)
        {
            for(i = 1; i <= p; i++)
                result *= n;
        }
        else if(p < 0)
        {
            for(i = 1; i <= -p; i++)
                result *= (1 / n);
        }
        else
            result = 1;
    }
    else
    {
        if(p == 0)
            result = 1;// 0?ơ方是一个有争议的数Q本题认Z(x)得到1
        else
            result = 0;
    }
    return result;
}
8?br />
#include <stdio.h>
double power(double n, int p);
int main(void)
{
    double x, xpow;
    int exp;

    printf("Enter a number and the positive integer power");
    printf(" to which\nthe number will be raised. Enter q");
    printf(" to quit.\n");
    while(scanf("%lf%d", &x, &exp) == 2)
    {
        xpow = power(x, exp);
        printf("%.3g to power %d is %.5g\n", x, exp, xpow);
        printf("Enter next pair of numbers or q to quit.\n");
    }
    printf("Hope you enjoyed this power trip -- bye!\n");
    return 0;
}
double power(double n, int p)
{
    double result = 1;

    if(n != 0)
    {
        if(p > 0)
            result = n * power(n, p-1);
        else if(p < 0)
            result = (1/n) * power(n, p+1);
        else
            result = 1;
    }
    else
    {
        if(p == 0)
            result = 1;// 0?ơ方是一个有争议的数Q本题认Z(x)得到1
        else
            result = 0;
    }
    return result;
}
9?br />
#include <stdio.h>
void to_base_n(unsigned long n, int range);
int main(void)
{
    unsigned long number;
    int range;
    printf("误入要转换的无W号整数和所规定的进制数Q?nbsp;\n");
    while(scanf("%lu %d", &number, &range) == 2)
    {
        if(range >= 2 && range <= 10)
        {
            printf("无符h?lu转换?dq制Cؓ(f)Q?nbsp;", number, range);
            to_base_n(number, range);
            putchar('\n');
            printf("误入要转换的无W号整数和所规定的进制数Q?nbsp;\n");
        }
        else
            printf("所规定的进制数的范围是2~10Q请输入正确的数字\n");
    }
    printf("Done!\n");
    return 0;
}
void to_base_n(unsigned long n, int range)
{
    int r;

    r = n % range;
    if(n >= range)
        to_base_n(n / range, range);
    putchar('0' + r);
    return;
}
10、(题意理解不清楚,借鉴CSDN——vs9841原作者的做法Q脑子太W,实在想不出来Q?br />
#include <stdio.h>
int Fibonacci(int n);
int main(void)
{
    int n = 9;
    printf("当n?dӞ斐LU_数gؓ(f)%d", n, Fibonacci(9));
    return 0;
}
int Fibonacci(int n)
{
    int a, b, i;
    a = 0;
    b = 1;
    int sum;
    if(n == 0)
        return 0;
    if(n == 1)
        return 1;
    else
    {
        for(i = 2; i <= n; i++)
        {
            sum = a + b;
            a = b;
            b = sum;
        }
        return sum;
    }
}
ȝQM来说~程l习(fn)相对以往来说要简单了Q但W?0题没明白什么意思,所以只能借鉴别h的了Q真是天下文章一大抄Q?img src ="http://www.aygfsteel.com/BeautifulMan/aggbug/428322.html" width = "1" height = "1" />

李阿昀 2015-11-22 23:03 发表评论
]]>
C Primer Plus W??字符输入/输出和输入确? 复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2015/11/21/428310.html李阿昀李阿昀Sat, 21 Nov 2015 12:12:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/21/428310.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428310.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/21/428310.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428310.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428310.html复习(fn)?/span>
1、putchar(getchar())是一个有效的表达式,它实C么功能?getchar(putchar())也有效吗Q?br />{:(x)
语句putchar(getchar())使程序读取下一个输入字Wƈ打印它,getchar()的返回g为putchar()的参数。getchar(putchar())则不是合法的Q因为getchar()不需要参数而putchar()需要一个参数?br />2、下面的每个语句实现什么功能?
    a.putchar('H');
    b.putchar('\007');
    c.putchar('\n');
    d.putchar('\b');
{:(x)
a. 昄字符H
b.如果pȝ使用ASCII字符~码Q则发出一声警?br />c.把光标移动到下一行的开?br />d.退后一?br />3、假设?zhn)有一个程序countQ该E序对输入的字符q行l计。用countE序设计一个命令行命o(h)Q对文gessay中的字符q行计数q将l果保存在名为essayct的文件中?br />{:(x)
count < essay > essayct
4、给定问?中的E序和文Ӟ下面哪个命o(h)是正的Q?br />{:(x)
a.essayct <essay
b.count essay
c.essay >count
{:(x)
c是正的?br />5、EOF是什么?
{:(x)
它是由getchar()和scanf()q回的信P一个特定的|Q用来表明已l到达了文g的结?br />6、对l出的输入,下面每个E序D늚输出是什么(假定ch是intcd的,q且输入是缓冲的Q?
a. 输入如下所C:(x)
    If you quit, I will.[enter]
    E序D如下所C:(x)
    while ((ch = getchar()) != 'i')
            putchar(ch);
b. 输入如下所C:(x)
    Harhar[enter]
    E序D如下所C:(x)
    while ((ch = getchar()) != '\n')
    {
               putchar(ch++);
               putchar(++ch);
    }
{:(x)
a.If you qu
b.HJacrthjacrt
7、C如何处理h不同文g和换行约定的不同计算机系l?
{:(x)
C的标准I/O库把不同的文件Ş式映ؓ(f)l一的流Q这样就可以按相同的方式对它们进行处理?br />8、在~冲pȝ中把数D入与字符输入相؜合时Q?zhn)所面(f)的潜在问题是什么?
{:(x)
数字输入跌I格和换行符Q但是字W输入ƈ不是q样。假设?zhn)~写了这L(fng)代码Q?br />
    int score;
    char grade;
    printf("Enter the score.\n");
    scanf("%d", &score);
    printf("Enter the letter grade.\n");
    grade = getchar();
假设(zhn)输入分?8Q然后按下回车键来把分数发送给E序Q?zhn)同时也发送了一个换行符Q它?x)成Z一个输入字W被d到grade中作为等U的倹{如果在字符输入之前q行了数字输入,应该添加代码以在获取字W输入之前剔除换行字W?br />~程l习(fn)
1?br />
#include <stdio.h>
int main(void)
{
    int ch;
    int count = 0;
    while((ch = getchar()) != EOF) // 包括换行W?/span>
        count++;
    printf("The number of characters is %d\n", count);
    return 0;
}
2、(觉得q题难的!Q!看了一些他人写的例子,直胡说八道!Q!不过q是完美解决了)
#include <stdio.h>
int main(void)
{
    int ch;
    int i = 0;

    while((ch = getchar()) != EOF)
    {
        if(ch >= 32)  // 可打印字W?/span>
        {
            putchar(ch);
            printf("/%d  ", ch);
            i++;
        }
        else if(ch == '\n')  // 打印换行W?/span>
        {
            printf("\\n");
            printf("/%d  ", ch);
            putchar(ch); // 清除输入~冲区里面的换行W?/span>
            = 0// i|ؓ(f)0重新开始计敎ͼ因ؓ(f)题目要求每次遇到一个换行符时就要开始打C个新?/span>
        }
        else if(ch == '\t')  // 打印制表W?/span>
        {
            printf("\\t");
            printf("/%d  ", ch);
            i++;
        }
        else // 打印控制字符
        {
            putchar('^');
            putchar(ch + 64);
            printf("/%d  ", ch);
        }
        if(i == 10)
        {
            putchar('\n');
            i = 0;
        }
    }
    return 0;
}
q行l果如下Q?br />
I love you!
I/73   /32  l/108  o/111  v/118  e/101   /32  y/121  o/111  u/117Q每行打?0个|
!/33  \n/10Q每ơ遇C个换行符时就开始一个新行)
My hello world^A
M/77  y/121   /32  h/104  e/101  l/108  l/108  o/111   /32  w/119Q每行打?0个|
o/111  r/114  l/108  d/100  ^A/1  \n/10Q每ơ遇C个换行符时就开始一个新行)
^Z
3?br />
#include <stdio.h>
#include <ctype.h>
int main(void)
{
    int ch;
    int low_count = 0, up_count = 0;

    while((ch = getchar()) != EOF)
    {
        if(islower(ch))
            low_count++;
        if(isupper(ch))
            up_count++;
    }
    printf("A number of capital letters: %d\n", up_count);
    printf("A number of lower case letters: %d\n", low_count);
    return 0;
}
4?br />
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
int main(void)
{
    char ch;
    long chars = 0L; // l计单词的字W数
    int words= 0; // 单词?/span>
    bool inword = false// 如果ch在一个单词中Q则inword为true

    printf("Enter text to be analyzed: \n");
    while((ch = getchar()) != EOF)
    {
        if(!isspace(ch) && !ispunct(ch))
            chars++;
        if(!isspace(ch) && !inword)
        {
            inword = true;
            words++;
        }
        if(isspace(ch) && inword)
            inword = false;
    }
    printf("The average number of words per word: %ld\n", chars / words);
    return 0;
}
5、(二分搜烦法W一ơ碰见,搞了大半天了Q借鉴的是CSDN-----vs9841作者的做法Q不q稍微加了下工)
#include <stdio.h>
char get_choice(void);
char get_first(void);
int main(void)
{
    int low = 1, high = 100, guess = 50;
    char ch;

    printf("Pick an integer from 1 to 100. I will try to guess it\n");
    printf("Unis your number %d?\n", guess);
    while((ch = get_choice()) != 'q')
    {
        if(ch == 'a')
        {
            printf("I knew I could do it!\n");
            break;
        }
        else if(ch == 'b')
        {
            printf("It is too small!\n");
            low = guess + 1;
        }
        else if(ch == 'c')
        {
            printf("It is too big!\n");
            high = guess - 1;
        }
        guess = (low + high) / 2;
        printf("Unis your number %d?\n", guess);
    }
    printf("Done!\n");
    return 0;
}
char get_choice(void)
{
    int ch;

    printf("Enter the letter of your choice: \n");
    printf("a. right       b. too small\n");
    printf("c. too big     q. quit\n");
    ch = get_first();
    while((ch < 'a' || ch > 'c') && ch != 'q')
    {
        printf("Please respond with a, b, c, or q.\n");
        ch = get_first();
    }
    return ch;
}
char get_first(void)
{
    int ch;

    ch = getchar();
    while(getchar() != '\n')
        continue;
    return ch;
}
6?br />
char get_first(void)
{
    int ch;

    while((ch = getchar()) == '\n')
        continue;
    while(getchar() != '\n')
        continue;
    return ch;
}
7?br />
#include <stdio.h>
#define WORK_OVERTIME 40
#define MULTIPLE 1.5
#define RATE1 0.15
#define RATE2 0.20
#define RATE3 0.25
#define BREAK1 300
#define BREAK2 450
#define BASE1 (BREAK1 * RATE1)
#define BASE2 (BASE1 + (BREAK2 - BREAK1) * RATE2)
char get_choice(void);
char get_first(void);
int main(void)
{
    int hour, choise;
    double total, tax, net_pay;
    double base_pay; // 基本工资{不能?define来定义了Q因为它要随着E序而改变了Q书上真是胡说八?/span>

    while((choise = get_choice()) != 'q')
    {
        switch(choise)
        {
        case 'a':
            base_pay = 8.15;
            break;  // break只是DE序qswitch语句Q蟩到switch之后的下一条语句!Q!
        case 'b':
            base_pay = 9.33;
            break;
        case 'c':
            base_pay = 10.00;
            break;
        case 'd':
            base_pay = 11.20;
            break;
        default:
            printf("Program error!\n");
            break;
        }
        printf("Please enter the hour used: ");
        scanf("%d", &hour); // 获取每周工作时数时没有像书上那样判断,我偷懒了Q!Q?/span>
        if(hour <= WORK_OVERTIME)
        {
            total = hour * base_pay;
            if (total <= BREAK1)
            {
                tax = total * RATE1;
                net_pay = total - tax;
            }
            else
            {
                tax = BASE1 + (total - BREAK1) * RATE2;
                net_pay = total - tax;
            }
        }
        else
        {
            total = base_pay * WORK_OVERTIME + (hour - WORK_OVERTIME) * MULTIPLE * base_pay;
            if(total <= BREAK2)
            {
                tax = BASE1 + (total - BREAK1) * RATE2;
                net_pay = total - tax;
            }
            else
            {
                tax = BASE2 + (total - BREAK2) * RATE3;
                net_pay = total - tax;
            }
        }
        printf("The total pay: %.2f; tax: %.2f; net pay: %.2f\n", total, tax, net_pay);
    }
    printf("Bye!\n");
    return 0;
}
char get_choice(void)
{
    int ch;

    printf("*****************************************************************\n");
    printf("Enter number corresponding to the desired pay rate or action:\n");
    printf("a) $8.75/hr\tb) $9.33/hr\n");
    printf("c) $10.00/hr\td) $11.20/hr\n");
    printf("q) quit\n");
    printf("*****************************************************************\n");
    printf("Please enter your choise: ");
    ch = get_first();
    while((ch < 'a' || ch > 'd') && ch != 'q')
    {
        printf("Please respond with a, b, c, d, or q.\n");
        ch = get_first();
    }
    return ch;
}
char get_first(void)
{
    int ch;

    while((ch = getchar()) == '\n')
        continue;
    while(getchar() != '\n')
        continue;
    return ch;
}
8?br />
#include <stdio.h>
char get_choice(void);
char get_first(void);
float get_float(void);
int main(void)
{
    char choise;
    float first_number, second_number;

    while((choise = get_choice()) != 'q')
    {
        printf("Enter first number: ");
        first_number = get_float();
        printf("Enter second number: ");
        second_number = get_float();
        switch(choise)
        {
        case 'a':
            printf("%.1f + %.1f = %.1f\n", first_number, second_number, first_number + second_number);
            break;
        case 's':
            printf("%.1f - %.1f = %.1f\n", first_number, second_number, first_number - second_number);
            break;
        case 'm':
            printf("%.1f * %.1f = %.1f\n", first_number, second_number, first_number * second_number);
            break;
        case 'd':
            if(second_number == 0)
            {
                printf("Enter a number other than 0: ");
                second_number = get_float();
                printf("%.1f / %.1f = %.1f\n", first_number, second_number, first_number / second_number);
            }
            else
                printf("%.1f / %.1f = %.1f\n", first_number, second_number, first_number / second_number);
            break;
        default:
            printf("Program error!\n");
            break;
        }
    }
    printf("Bye.\n");
    return 0;
}
char get_choice(void)
{
    int ch;

    printf("Enter the operation of your choice: \n");
    printf("a. add\ts. subtract\n");
    printf("m. multiply\td. divide\n");
    printf("q. quit\n");
    ch = get_first();
    while(ch != 'a' && ch != 's' && ch != 'm' && ch != 'd' && ch != 'q')
    {
        printf("Please respond with a, s, m, d, or q.\n");
        ch = get_first();
    }
    return ch;
}
char get_first(void)
{
    int ch;

    while((ch = getchar()) == '\n')
        continue;
    while(getchar() != '\n')
        continue;
    return ch;
}
float get_float(void)
{
    float input;
    char ch;

    while((scanf("%f", &input)) != 1)
    {
        while((ch = getchar()) != '\n')
            putchar(ch);
        printf(" is not a number.\nPlease enter a ");
        printf("number, such as 2.5, -1.78E8, or 3: ");
    }
    return input;
}



李阿昀 2015-11-21 20:12 发表评论
]]>
C Primer Plus W??C控制语句Q分支和跌{ 复习(fn)题与~程l习(fn)http://www.aygfsteel.com/BeautifulMan/archive/2015/11/20/428296.html李阿昀李阿昀Thu, 19 Nov 2015 16:02:00 GMThttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/20/428296.htmlhttp://www.aygfsteel.com/BeautifulMan/comments/428296.htmlhttp://www.aygfsteel.com/BeautifulMan/archive/2015/11/20/428296.html#Feedback0http://www.aygfsteel.com/BeautifulMan/comments/commentRss/428296.htmlhttp://www.aygfsteel.com/BeautifulMan/services/trackbacks/428296.html    a.100 > 3 && 'a' >&nbs...  阅读全文

李阿昀 2015-11-20 00:02 发表评论
]]>
վ֩ģ壺 ͩ| ͨμ| ƽ| | | ǿ| | | γ| | | ɽ| | ƽ| | ˮ| ˮ| | | Ӧ| | | | | | | | | | н| | | ̨| ӯ| ̫| ָ| | ٹ| ݶ| | ʯ|