关于VS2017使用中常见的几个问题
一、在VS2017環(huán)境中編譯,使用scanf 時(shí),將scanf 寫(xiě)成 scanf_s 就可以從鍵盤(pán)輸入。
二、VS2017使用時(shí),調(diào)試窗口會(huì)一閃而過(guò),需要寫(xiě)一個(gè)頭文件 #include <stdlid.h> ,然后在 return 0 ;之前寫(xiě) system ("pause");即可避免這種現(xiàn)象。
三、以下是幾個(gè)經(jīng)典例題
1.可以接收鍵盤(pán)字符,如果是小寫(xiě),則輸出大寫(xiě);如果是大寫(xiě),則輸出小寫(xiě);如果是數(shù)字,則不輸出
#include <stdio.h>
#include <stdlib.h>
?
int main()
{
?? ?int ch = 0;
?? ?while ((ch = getchar()) != EOF)
?? ?{
?? ??? ?if (ch >= 65 && ch <= 90)
?? ??? ?{
?? ??? ??? ?ch = ch + 32;
?? ??? ??? ?putchar(ch);
?? ??? ?}
?? ??? ?else if (ch >= 97 && ch <= 122)
?? ??? ?{
?? ??? ??? ?ch = ch - 32;
?? ??? ??? ?putchar(ch);
?? ??? ?}
?? ??? ?else if (ch >= '0' && ch <= '9')
?? ??? ?{
?? ??? ??? ?;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ?putchar(ch);
?? ??? ?}
?? ?}
?? ?system("pause");
?? ?return 0;
}
?
2.for 語(yǔ)句經(jīng)典例題
輸出一個(gè)菱形
?
#include<stdio.h>
#include<stdlib.h>
int main()
{
? ? ?int line = 0;
? ? ?int i = 0;
? ? ?scanf_s("%d", &line);
? ? ?for (i = 0; i < line; i++)
? ? ?{
? ? ? ? ? int j = 0;
? ? ? ? ? for (j = 0; j < line-1-i ; j++)
? ? ? ? ? {
? ? ? ? ? ? ? ?printf(" ");
? ? ? ? ? }
? ? ? ? ? for (j = 0; j < 2 * i + 1; j++)
? ? ? ? ? {
? ? ? ? ? ? ? ?printf("*");
? ? ? ? ? }
? ? ? ? ? printf("\n");
? ? ?}
? ? ?for (i = 0; i < line-1; i++)
? ? ?{
? ? ? ? ? int j = 0;
? ? ? ? ? for (j = 0; j <=i; j++)
? ? ? ? ? {
? ? ? ? ? ? ? ?printf(" ");
? ? ? ? ? }
? ? ? ? ? for (j = 0; j < (line-1-i)*2 - 1; j++)
? ? ? ? ? {
? ? ? ? ? ? ? ?printf("*");
? ? ? ? ? }
? ? ? ? ? printf("\n");
? ? ?}
? ? ?system("pause");
? ? ?return 0;
}
?
總結(jié)
以上是生活随笔為你收集整理的关于VS2017使用中常见的几个问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 如何用VS2017打开VS2010(低版
- 下一篇: VC++之自定义消息