⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lets_go!.c

📁 C.Game.Programming.For.Dummies.原码
💻 C
字号:
#include <stdio.h>
#include <string.h>

void main()
{
    struct solarsystem {
        char planet[8];
        double population;
    };

    struct solarsystem planets[9] = {
        "Mercury", 0,
        "Venus", 0,
        "Earth", 5.5E9,
        "Mars", 0,
        "Jupiter", 0,
        "Saturn", 0,
        "Uranus", 0,
        "Neptune", 0,
        "Pluto", 0
        };
    struct solarsystem temp;

    int x;

    puts("Solar System Data");

    for(x=0;x<9;x++)
        printf("Planet %i: %s, Population: %.0f\n",\
            x+1,
            planets[x].planet,
            planets[x].population);

    puts("\nAfter we swap with Jupiter:");

/* Copy Jupiter's data to temp */

    strcpy(temp.planet,planets[4].planet);
    temp.population = planets[4].population;

/* Copy Earth to Jupiter */

    strcpy(planets[4].planet,planets[2].planet);
    planets[4].population = planets[2].population;

/* Copy temp to Earth */

    strcpy(planets[2].planet,temp.planet);
    planets[2].population=temp.population;

    for(x=0;x<9;x++)
        printf("Planet %i: %s, Population: %.0f\n",\
        	x+1,
            planets[x].planet,
            planets[x].population);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -