C/C++教程

c primer plus 12 编程练习

本文主要是介绍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);
}

 

#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 编程练习的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!