1 double p; 2 char s[10]; 3 memset(s,0,sizeof(s)); 4 s[0]=‘0‘; 5 s[1]=‘.‘; 6 for (int i=2;i<10;i++) 7 { 8 s[i]=rand()%10+‘0‘; 9 } 10 p=atof(s); 11 cout << p <<endl;
时间: 2024-11-13 10:02:41
1 double p; 2 char s[10]; 3 memset(s,0,sizeof(s)); 4 s[0]=‘0‘; 5 s[1]=‘.‘; 6 for (int i=2;i<10;i++) 7 { 8 s[i]=rand()%10+‘0‘; 9 } 10 p=atof(s); 11 cout << p <<endl;