#include <stdio.h>
struct DB {
char name[ 20 ] ;
int age;
char hometown[ 20 ] ;
} ;
int main( )
{
struct DB db[ 10 ] ;
int i, n, count = 0 ;
while ( 1 ) {
printf ( " 1:create a database\n " ) ; printf ( " 2:show the database\n " ) ; switch ( n) {
case 1 :
printf ( " Please input name, age and hometown\n " ) ; printf ( "db[%d].name=" , count
) ; scanf ( "%19s" , db
[ count
] .
name ) ; scanf ( "%d" , & db
[ count
] .
age ) ; printf ( "db[%d].hometown=" , count
) ; scanf ( "%19s" , db
[ count
] .
hometown ) ; count++;
break ;
case 2 :
printf ( " name age homwtown\n " ) ; for ( i = 0 ; i < count; i++ ) {
printf ( " %s %d %s\n " , db
[ i
] .
name , db
[ i
] .
age , db
[ i
] .
hometown ) ; }
break ;
case 3 :
return 0 ;
}
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgpzdHJ1Y3QgREIgewoJY2hhcgluYW1lWzIwXTsKCWludAlhZ2U7CgljaGFyCWhvbWV0b3duWzIwXTsKfTsKCmludCBtYWluKCkKewoJc3RydWN0IERCIGRiWzEwXTsKCWludCBpLCBuLCBjb3VudCA9IDA7CgoJd2hpbGUgKDEpIHsKCQlwcmludGYoIiAxOmNyZWF0ZSBhIGRhdGFiYXNlXG4iKTsKCQlwcmludGYoIiAyOnNob3cgdGhlIGRhdGFiYXNlXG4iKTsKCQlwcmludGYoIiAzOmV4aXRcbiIpOwoJCXByaW50ZigiIG49Iik7CgkJc2NhbmYoIiVkIiwgJm4pOwoJCXByaW50ZigiJWRcbiIsIG4pOwoJCXN3aXRjaCAobikgewoJCWNhc2UgMToKCQkJcHJpbnRmKCIgUGxlYXNlIGlucHV0IG5hbWUsIGFnZSBhbmQgaG9tZXRvd25cbiIpOwoJCQlwcmludGYoImRiWyVkXS5uYW1lPSIsIGNvdW50KTsKCQkJc2NhbmYoIiUxOXMiLCBkYltjb3VudF0ubmFtZSk7CgkJCXByaW50ZigiZGJbJWRdLmFnZT0iLCBjb3VudCk7CgkJCXN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