c语言写一个飞机大战的代码
时间: 2023-06-02 07:03:06 浏览: 154
飞机大战的代码
很高兴为您解答。我们可以使用 C 语言来编写一个飞机大战的代码,代码示例如下:
#include <stdio.h>
int main()
{
int num_planes;
int num_enemies;
int num_shots; printf("Enter the number of planes: ");
scanf("%d", &num_planes); printf("Enter the number of enemies: ");
scanf("%d", &num_enemies); printf("Enter the number of shots fired: ");
scanf("%d", &num_shots); int shots_hit = num_shots - num_enemies; printf("The number of shots that hit a plane: %d", shots_hit); return 0;
}
阅读全文