Р#include Р#include

全文预览

电大《C++语言程序设计》第1、2、3、4次作业及答案

上传者:相惜 |  格式:doc  |  页数:23 |  大小:109KB

文档介绍
rintf("PP "); break;Р?default:Р printf("BB "); break;Р?}Р}Рvoid main() {Р?char a1 = 'b', a2 = 'C', a3 = 'f';Р?SB(a1); SB(a2); SB(a3); SB('A');Р?printf("\n");Р}Р程序代码:Р#include <stdio.h>Р#include <stdlib.h>Рdouble SD(int a, int b, char op) {Р?double x;Р?switch(op) {Р?case '+': x = a + b; break;Р?case '-': x = a - b; break;Р?case '*': x = a * b; break;Р?case '/': if(b) x = (double)a/b; else exit(1); break;Р?default: { printf("运算符错!\n"); exit(1); }Р?}Р?return x;Р}Рvoid main() {Р?int x = 20, y = 8;Р?printf("%3.2lf ", SD(x, y, '-'));Р?printf("%3.2lf ", SD(x, y, '*'));Р?printf("%3.2lf\n", SD(x + y, y, '/'));Р}Р程序代码:Р#include <stdio.h>Рvoid WF(int x, int y) {Р?x = x + y;Р?y = x + y;Р?printf("subs: x, y = %d, %d\n", x, y);Р}Рvoid main() {Р?int x = 18, y = 23;Р?printf("main: x, y = %d, %d\n", x, y);

收藏

分享

举报
下载此文档