c primer plus 12 编程练习

 

1、

#include <stdio.h>

void critic(int * ar1);

int main(void)
{
    int num;
    
    printf("how many pounds to a firkin of butter? \n");
    scanf("%d", &num);
    
    while(num != 56)
        critic(&num);
    
    printf("you must have looked the answer!\n");
    
    return 0;
}

void critic(int * ar1)
{
    printf("wrong, try again!\n");
    scanf("%d", ar1);
}

c primer plus 12 编程练习

 

#include <stdio.h>

void critic(int * n);

int main(void)
{
    int units;
    
    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 * n)
{
    printf("No luck, my friends, try again.\n");
    scanf("%d", n);
}

c primer plus 12 编程练习

 

上一篇:c++primer笔记十五、面向对象程序设计


下一篇:超硬核知识:两万字总结《C++ Primer》要点!