C/C++の宿題を片付けます 117代目at TECH
C/C++の宿題を片付けます 117代目 - 暇つぶし2ch653:デフォルトの名無しさん
08/11/12 08:32:46
>>610
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