這裏是我的 WeChat
非緊急事務,請盡量不要使用此聯係方式,還請各位好友海涵(不然我就要收費了)
咨詢内容
我可以爲您解答以下問題:
- 單片機、電路類
- TC264/TC377/STC32/STM32/STC89C52/ESP32/其它類51單片機/其它部分單片機 架構和軟、硬件開發
- 各類單片機軟件開發
- 單片機電路設計
- 軟件開發類
- 前端技術和開發(Vue、React、原生HTML等)
- 博客設計和運營相關問題
- 全棧開發設計和架構
- 後端開發
AMA價目表($)
時項 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
1小時 | 5.00 | 9.00 | 13.50 | 18.00 | 22.50 |
2小時 | 12.31 | 22.16 | 33.23 | 44.31 | 55.39 |
3小時 | 19.74 | 35.53 | 53.30 | 71.06 | 88.83 |
4小時 | 28.22 | 50.80 | 76.19 | 101.59 | 126.99 |
5小時 | 37.64 | 67.75 | 101.63 | 135.50 | 169.38 |
計算公式
- 基礎價格:
- 時間係數:
- 話題係數計算函數:
收費明細:只取整,即計算完畢後取整數;若換算為人民幣, 乘以匯率後繼續取整
價格計算代碼
#include <stdio.h>
#include <math.h>
#include <ctype.h>
// 计算AMA咨询价格
double calculate_ama_price(int t, int n) {
const double base_price = 5.0; // 基础价格5元
const double time_exponent = 1.3; // 时间指数
const double topic_discount = 0.9; // 多话题折扣系数
// 计算时间系数
double time_factor = pow(t, time_exponent);
// 计算话题系数
double topic_factor = (n == 1) ? 1.0 : (topic_discount * n);
// 计算总价并四舍五入保留两位小数
double total_price = base_price * time_factor * topic_factor;
total_price = round(total_price * 100) / 100;
return total_price;
}
// 获取正整数输入
int get_positive_input(const char* prompt) {
int value;
char ch;
while(1) {
printf("%s", prompt);
// 检查是否成功读取整数
if(scanf("%d", &value) != 1) {
// 清除错误输入
while((ch = getchar()) != '\n' && ch != EOF);
printf("输入无效,请输入正整数\n");
continue;
}
// 检查是否为正数
if(value <= 0) {
printf("请输入大于0的整数\n");
continue;
}
// 清除输入缓冲区中的剩余字符
while((ch = getchar()) != '\n' && ch != EOF);
return value;
}
}
int main() {
printf("=== AMA咨询价格计算器 ===\n");
// 获取用户输入
int hours = get_positive_input("请输入咨询时间(小时): ");
int topics = get_positive_input("请输入话题数量: ");
// 计算价格
double price = calculate_ama_price(hours, topics);
// 显示结果
printf("\n=== 计算结果 ===\n");
printf("咨询时间: %d小时\n", hours);
printf("话题数量: %d个\n", topics);
printf("总价格: $%.2f\n", price);
// 显示计算公式
printf("\n计算公式: \n");
printf("5 × %d^1.3 × ", hours);
if(topics == 1) {
printf("1 = $%.2f\n", price);
} else {
printf("0.9 × %d = $%.2f\n", topics, price);
}
return 0;
}
