电影院规定,零售票价30元每张,20张及以上属于团体票,25元每张。编程,输入购票数量,计算总票价并输出。
#include <stdio.h>
int main() {
int amount;
float price;
printf("请输入购票数量:");
scanf("%d", &amount);
if (amount >= 20) {
price = amount * 25.0;
} else {
price = amount * 30.0;
}
printf("总票价为:%.2f 元\n", price);
return 0;
}
#include <stdio.h>
int main()
{
// 定义零售票价和团体票价
int retail_price = 30;
int group_price = 25;
// 输入购票数量
int num_tickets;
printf("请输入购票数量:");
scanf("%d", &num_tickets);
// 计算总票价
int total_price;
if (num_tickets >= 20)
total_price = num_tickets * group_price;
else
total_price = num_tickets * retail_price;
// 输出总票价
printf("总票价为:%d\n", total_price);
return 0;
}
不知道你这个问题是否已经解决, 如果还没有解决的话:#include <stdio.h>
int main(){
int a[5]={1,3,4,2,5};
int *num[5]={&a[0],&a[1],&a[2],&a[3],&a[4]}; //指针数组
int **p; //定义一个指向指针数据的指针变量
p=num; //p指向num的首地址
for (int i = 0; i < 5; i++) {
printf("%d",**p); //输出&num[i]里面的元素
p++;
printf(" ");
}
return 0;
}
结果:
1 3 4 2 5
Process finished with exit code 0
抱歉,由于没有具体的问题描述,我无法给出解决方案。请提供具体的问题描述,让我能够更好地为您提供帮助。