vs2015 C语言
1、C语言输入一行未知个数数字存入数组
#include <stdio.h>
int main()
{
int a[100];
int i = 0, j = 0;
do
{
scanf("%d",&a[i]);
i++;
}
while(getchar() != '\n');
a[i] = '\0';
for(j = i - 1; j >= 0; j--)
{
printf("%d = %d ",j,a[j]);
}
printf("\n");
return 0;
}
疑问:按照如下的代码会出现问题,输入的第一个数消失了。
#include <stdio.h>
int main()
{
int a[100];
int i = 0, j = 0;
while(getchar() != '\n')
{
scanf("%d",&a[i]);
i++;
}
a[i] = '\0';
for(j = i - 1; j >= 0; j--)
{
printf("%d = %d ",j,a[j]);
}
printf("\n");
return 0;
}
参考:https://www.cnblogs.com/wd1001/p/4826855.html
2、VS2015编写C语言程序的流程
参考:http://c.biancheng.net/view/454.html
3、无法解析的外部符号 _main,该符号在函数 ___tmainCRTStartup 中被引用 解决方法
参考:https://blog.csdn.net/weixin_41353276/article/details/78886566
4、VS运行框一闪而退解决方法
参考:https://blog.csdn.net/rannianzhixia/article/details/66968219?locationNum=6&fps=1
5、VS多行注释和取消多行注释
注释: 先CTRL+K,然后CTRL+C
取消注释: 先CTRL+K,然后CTRL+U
6、浮点输出时,设置输出小数点位数
printf(“%0.8f”,x); //x变量以小数形式输出,保留8位小数。
7、对数
参考:https://blog.csdn.net/weixin_37609825/article/details/79850874
#include<stdio.h>
#include<math.h>
int main(){
printf("%f\n",log(10)); //以e为底的对数函数
printf("%f\n",log10(100)); //以10为底的对数函数
printf("%f\n",log(8)/log(2)); //计算log2^8,运用换底公式
printf("%f\n",exp(1)); //计算自然常数e
return 0;
}
参考:https://blog.csdn.net/weixin_37609825/article/details/79850874