C/C++の宿題を片付けます 117代目 at TECH
[2ch|▼Menu]
653:デフォルトの名無しさん
08/11/12 08:32:46
>>610 A
struct Point {
double x;
double y;
};
void input_point_p(struct Point *p){
printf("X:");
scanf("%lf", &p->x);
printf("Y:");
scanf("%lf", &p->y);
}
void print_v_p2(struct Point *p){
printf("%f %f\n", p->x, p->y);
}
int main(void){
struct Point *p; /* 構造体ポインタ変数 p */
int num, i;
printf("Input number of vector: ");
scanf("%d", &num);
for (i=0; i< num; i++) {
p = malloc(sizeof(struct Point)); /* malloc を使って領域確保 */
if( p == NULL ) {
printf( "memory cannot alloc!\n" );
exit( 1 );
}
input_point_p(p); /* 関数を使って要素を代入 */
print_v_p2(p); /* 関数を使って要素の表示 */
free(p); /* メモリの解放 */
}
return 0;
}


次ページ
続きを表示
1を表示
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4989日前に更新/337 KB
担当:undef