Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- typedef struct {
- float x; /* x */
- float y; /* y */
- } point;
- point* random_point(){
- srand((unsigned) time(NULL));
- point* p = (point*)malloc(sizeof(point));
- float rnd;
- rnd = (rand() % 1001 - 500)/10.0;
- p->x = rnd;
- rnd = (rand() % 1001 - 500)/10.0;
- p->y = rnd;
- return p;
- }
- int main(void)
- {
- point* p;
- p = random_point();
- printf("生成された座標: (%.1f,%.1f)\n", p->x, p->y);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment