摘要:
/* 求解简单的四则运算表达式 */#includeint main(void){ double value1,value2; char op; printf("Type in an expression:"); scanf_s("%lf%clf",&value1,&op,&value2); switch(op){ case'+': printf("=%.2f\n",value1+value2); break; case'-': printf("=%.2f\n" 阅读全文
摘要:
/* 查询自动售货机中商品的价格 */#includeint main(void){ int choice,i; double price; for(i=1;i<=5;i++){ printf("[1]Select crisps\n"); printf("[2]Select popcorn\n"); printf("[3]Select chocolate\n"); printf("[4]Select cola\n"); printf("[0]Select exit\n"); printf( 阅读全文
摘要:
/* 统计字符,包括英文字母、数字字符和其他字符 */#includeint main(void){ int digit,letter,other; char ch; int i; digit=letter=other=0; printf("Enter 10 characters:"); for(i=1;i='a'&&ch='A'&&ch='0'&&ch<='9') digit++; else other++; } printf("letter=% 阅读全文