2025-03-10 18:53:27 +08:00

57 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### C语言-1
```c
/*---------------------------------------------------------
【程序设计】程序将由数字字符组成的字符串转换为10进制实数
例如将"123.4567"转换为123.45670。
输出如下:
123.45670
0.12345
4567.00000
------------------------------------------------------------------------
注意部分源程序给出如下。请勿改动主函数main或其它函数中给出的内容仅在
Program-End之间填入若干语句。不要删除标志否则不得分。
---------------------------------------------------------*/
#include<stdio.h>
#include<ctype.h>
double conver(char s[]){
int I,i,poi;
double F,p;
F=I=i=poi=0;
p=0.1;
/**********Program**********/
while(s[i] != '.'){
I*=10;
I+=s[i]-48;
i++;
}
i++;
while(s[i] != '\0'){
F+=(s[i]-48)*p;
p*=0.1;
i++;
}
/********** End **********/
return I+F;
}
int main()
{
char d[3][15]={"123.4567","0.12345","4567.0"};
int i;
for(i=0;i<3;i++)
printf("%12.5f\n",conver(d[i]));
return 0;
}
```
### C语言-2
```c
```