《C语言程序设计》苏小红课后习题答案高等教育出社 下载本文

main() {

int year,flag;

printf(\ a year:\scanf(\

if(year%4==0&&year@0!=0||year@0==0) {

flag=1; } else {

flag=0; }

if(flag==1) {

printf(\ is a leap year !\\n\} else {

printf(\ is not a leap year !\\n\} } 5.6

#include main() {

int year,flag;

printf(\ a year:\scanf(\

flag=year@0==0||year%4==0&&year0!=0?1:0; if(flag==1&&flag!=0) {

printf(\ is a leap year !\\n\} else {

printf(\ is not a leap year !\\n\} }

5.7

#include main() {

char ch;

printf(\scanf(\if(ch>='a'&&ch<='z') {

ch=getchar();

ch=ch-32;

printf(\}

else if(ch>='A'&&ch<='Z') {

ch=getchar(); ch=ch+32;

printf(\} else {

printf(\} }

5.8

#include main() {

char ch;

printf(\scanf(\

if(ch>=48&&ch<=57) {

printf(\ 是数字字符\\n\}

else if(ch>=65&&ch<=90) {

printf(\ 是大写字母\\n\}

else if(ch>=97&&ch<=122) {

printf(\ 是小写字母\\n\}

else if(ch==32) {

printf(\ 是空格\\n\} else {

printf(\ 是其他字符\\n\}

} 5.9

#include main() {

int score,grade;

printf(\ score:\scanf(\grade=score/10;

if(score<0||score>100) {

printf(\ error\\n\}

if(score>=90&&score<=100) {

printf(\}

else if(score>=80&&score<90) {

printf(\}

else if(score>=70&&score<80) {

printf(\}

else if(score>=60&&score<70) {

printf(\}

else if(score>=0&&score<60) {

printf(\ -E\\n\}

}

5.10

#include main() {

int year,month;

printf(\ year,month:\

scanf(\if(month>12||month<=0) {

printf(\ month\\n\} else {

switch(year,month) {

case 12: case 10: case 8: case 7: case 5: case 3: case 1:

printf(\ 天\\n\

break;

case 11: case 9: case 6: case 4:

printf(\ 天\\n\

break;