Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
#include<math.h>
#include<time.h>
#include<stdlib.h>
#define E 4
/*
#define MAX 100
#define X_Length 100.0E-09 //X-length[meter]
#define Y_Length 100.0E-09 //Y-length[meter]
#define N_EGFR 10 //EFGRの個数[#]
#define a 2.0E-9 //格子幅 [meter]
*/
//MOLECULEaa
struct MOLECULE{
char s; //分子の状態(m:monor,d:dimer)
int x; //x座標[0,1,…,N_X] (N_X+1)個
int y; //y座標[0,1,…,N_Y] (N_Y+1)個
};
void swap(double *a,double *b,int i,int j,int tmp[]){
double t=*a;
int x;
*a=*b;
*b=t;
x=tmp[i];
tmp[i]=tmp[j];
tmp[j]=x;
}
/* 分子をランダムに配置 */
void pos(struct MOLECULE m[]){
int i,j;
for(i=0;i<=9;i++){
(m[i].x)=rand()%51;
(m[i].y)=rand()%51;
}
for(i=0;i<=9;i++){
for(j=i+1;j<=9;j++){
if(m[i].x == m[j].x && m[i].y== m[i].y){
m[i].x=rand()%51;
m[i].y=rand()%51;
}
}
}
}
int Select_Event(double p[],int tmp[]){
int i=0;
int r=0;
double select;
while(i<E-1){
r=rand()%E;
if(r==i){
continue;
}
swap(&p[i],&p[r],i,r,tmp);
i++;
}
select=(double)(rand()%101)/100;
//printf("select=[%f]ntmp=[%d,%d,%d,%d]n",select,tmp[0],tmp[1],tmp[2],tmp[3]);
double n=0;
double *p1=p;
for(i=0;i<E-1;i++){
n += (*p1);
if(n >= select){
return tmp[i];
}
p1++;
}
return -1;
}
int main(void){
double g[E]={25,25,25,25},gmax=0.0;//上、下、左、右
double p[E];
int tmp[E],n;
int *p1;
double *p2,*p3;
int i,sel_event;
//int arr[51][51];
int select;
//int position[10][2];
//int f1,f2,f3,f4;
struct MOLECULE m[10];
srand((unsigned)time(NULL));
pos(m); //分子割り振り
// select = rand()%10;
p1=tmp;
for(i=0;i<E-1;i++){
*p1=i+1;
p1++;
}
p2=g;
for(i=0;i<E-1;i++){
gmax+=(*p2++);
}
/*
for(i=0;i<9;i++){
if(select==i)
i++;
if((position[select][0]+1) == position[i][0] && position[select][1] == position[i][0])
g[0]=0;
if((position[select][0]-1) == position[i][0] && position[select][1] == position[i][0])
g[0]=1;
if((position[select][0]) == position[i][0] && position[select][1]+1 == position[i][0])
g[0]=2;
if((position[select][0]) == position[i][0] && position[select][1]-1 == position[i][0])
g[0]=3;
}
*/
//g[0]=0;
//g[3]=0;
p2=p;
p3=g;
for (i=0;i<E;i++){ /* g[]から確率を計算して代入 */
*p2=(*p3/gmax);
p2++;p3++;
}
i = 0;
n=0;
while(n<100){
select = rand()%10;
for(i=0;i<9;i++){
if(select==i)
i++;
if((m[select].x)+1 == m[i].x && m[select].y == m[i].y)
g[0]=0;
if((m[select].x)-1 == m[i].x && m[select].y == m[i].y)
g[0]=1;
if( m[select].x == m[i].x && (m[select].y)+1 == m[i].y)
g[0]=2;
if( m[select].x == m[i].x && (m[select].y)-1 == m[i].y)
g[0]=3;
}
p1=tmp;
for(i=0;i<E-1;i++){
*p1=i+1;
p1++;
}
sel_event=Select_Event(p,tmp);
if(g[sel_event]==0)
printf("別の分子がいますn");
else if(sel_event ==0){
printf("event=[%d]n",tmp[sel_event]); //上
m[select].y += 1;
n++;
}
else if(sel_event ==1){
printf("event=[%d]n",tmp[sel_event]); //下
m[select].y -= 1;
n++;
}
else if(sel_event ==2){
printf("event=[%d]n",tmp[sel_event]); //左
m[select].x -= 1;
n++;
}
else if(sel_event ==3){
printf("event=[%d]n",tmp[sel_event]); //右
m[select].y += 1;
n++;
}
printf("[%d,%d],[%d,%d],[%d,%d],[%d,%d],[%d,%d],[%d,%d],[%d,%d],[%d,%d],[%d,%d],[%d,%d],n",m[0].x,m[0].y,m[1].x,m[1].y,m[2].x,m[2].y,m[3].x,m[3].y,m[4].x,m[4].y,m[5].x,m[5].y,m[6].x,m[6].y,m[7].x,m[7].y,m[8].x,m[8].y,m[9].x,m[9].y);
printf("%dn",n);
}
return 0;
}
![]() |
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team