我知道Visual Studio可以自动格式化,使我的方法和循环缩进正确,但我找不到设置。
当前回答
#include "stdafx.h"
#include <stdio.h>
int main(){
char filename[15];
printf("Enter file name:");
scanf("%s", filename);
Automat(filename);
freq(filename);
}
int Automat(char filename[]){
FILE*fp;
char c;
int state = 1;
int duma = 0;
fp = fopen(filename, "r");
if (fp == NULL){
printf("Error");
system("pause");
}
while (!feof(fp)){
c = fgetc(fp);
switch (state){
case 1:
if (c == '\t' || c == '\n' || c == ' '){
state = 3;
break;
}
case 2:
if (c >='A'|| c<='Z'){
break;
}
case 3: duma++;
state = 1;
break;
}
}
printf("Broq e : %d\n", duma);
return 1;
}
int freq(char filename[]){
FILE*fp;
char c;
int state = 1, sequence = 0;
fp = fopen(filename, "r");
if (fp == NULL){
printf("Error");
system("pause");
}
while (!feof(fp)){
c = fgetc(fp);
switch (state){
case 1:
if (c >= 'A' && c <= 'Z'){
state = 2;
break;
}
case 2:
if (c == '\t' || c == '\n'||c == ' '){
sequence++;
state = 1;
break;
}
}
}
printf("Sequence is : %d\n", sequence);
}
其他回答
如果你显示HTML源代码编辑工具栏,还有一个“格式化整个文档”按钮。
右键点击:
它可以在Visual Studio 2015中工作,可能是更早的版本。
我曾经使用这些组合。我在保存文档时自动化了这个过程。你可以尝试我的扩展格式文件保存。
使用连续格式化扩展(商业的,由我开发的),代码在您键入时自动格式化。
简单地按Ctrl+Shift+我将做的工作。
推荐文章
- 如何使制表符4个空间而不是8个空间在纳米?
- Nuget连接尝试失败“无法为源加载服务索引”
- 在Visual Studio中查看多个项目/解决方案
- Visual Studio打开默认浏览器,而不是Internet Explorer
- 如何在Atom中更改缩进模式?
- csproj文件中的“Service Include”是干什么用的?
- 如何在Visual Studio中找到堆栈跟踪?
- 使用不同的Web。在开发和生产环境中进行配置
- 如何缩进/格式选择的代码在Visual Studio代码?
- 是否有一种方法可以在Visual Studio中删除一行而不剪切它?
- Microsoft Visual Studio的推荐插件
- Visual Studio: ContextSwitchDeadlock
- Visual Studio:如何打破处理异常?
- VS 2017 Git本地提交数据库。每次提交时锁定错误
- 无法启动IIS Express Web服务器,注册URL失败,访问被拒绝