#include <iostream>
using namespace std;
#include <windows.h>
#include <conio.h>
#include <stdlib.h> //system函数所需头文件
#define stoptimelong 500 //Sleep函数以毫秒为单位,Sleep(500);表示停半秒
#pragma warning(disable:4996)
//中文的所有符号和等全是小于0的
string str = "汉字里有english也能正确显示,hehe";
int main17060603()
{
int i = 0, len = str.length();
while (i<len)
{
if (str[i] < 0)
{
printf("%c%c", str[i], str[i + 1]);
i++;
}
else
{
printf("%c", str[i]);
}
i++;
}
return 0;
}
//跳到屏幕指定坐标
void gotoxy(int x, int y)
{
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
HANDLE hConsoleOut;
hConsoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsoleOut, &csbiInfo);
csbiInfo.dwCursorPosition.X = x;
csbiInfo.dwCursorPosition.Y = y;
SetConsoleCursorPosition(hConsoleOut, csbiInfo.dwCursorPosition);
}
int main17060602(void)
{
int x = 14, y = 5;
gotoxy(x, y);
printf("你好!");
Sleep(stoptimelong);
// system("color 10"); //调用控制台颜色管理命令,可以改变屏幕和字体的颜色
printf("欢");
Sleep(stoptimelong);
printf("迎");
Sleep(stoptimelong);
printf("来");
Sleep(stoptimelong);
printf("到");
// system("color 19");
Sleep(stoptimelong);
printf("计");
Sleep(stoptimelong);
printf("算");
Sleep(stoptimelong);
printf("机");
// system("color 37");
Sleep(stoptimelong);
printf("冒");
Sleep(stoptimelong);
printf("险");
// system("color 46");
Sleep(stoptimelong);
printf("世");
Sleep(stoptimelong);
printf("界");
Sleep(stoptimelong);
printf("!");
Sleep(stoptimelong);
cout << endl;
getchar();
return 0;
}
int main17060802()
//int main()
{
cout << "I made it!" << endl;
char my1[] = "一别都门三改火,天涯踏尽红尘。\
依然一笑作春温。无波真古井,有节是秋筠。\
惆怅孤帆连夜发,送行淡月微云。\
尊前不用翠眉颦。人生如逆旅,我亦是行人。";
char my[] = "定风波、莫听穿林打叶声。宋代:苏轼。\
三月七日,沙湖道中遇雨。雨具先去,同行皆狼狈,余独不觉,已而遂晴,故作此词。\
莫听穿林打叶声,何妨吟啸且徐行。竹杖芒鞋轻胜马,谁怕?一蓑烟雨任平生。\
料峭春风吹酒醒,微冷,山头斜照却相迎。回首向来萧瑟处,归去,也无风雨也无晴。";
//char my[] = "一别都门三改火,天涯踏尽红尘。依然一笑作春温。无波真古井,有节是秋筠。惆怅孤帆连夜发,送行淡月微云。尊前不用翠眉颦。人生如逆旅,我亦是行人。";
char s[3] = { 0 };
char over[] = "。"; //中文的句号字符串
cout << endl << endl << " ";
//逐个输出汉字
for (int k = 0; k < strlen(my); k += 2)
{
printf("%c%c", my[k], my[k + 1]); //每两个字符表示一个汉字
Sleep(300);
sprintf(s, "%c%c", my[k], my[k + 1]); //把一个中文的字符转化存到s中
//sprintf_s(s, "%c%c", my[k], my[k + 1]);
if (strcmp(s, over) == 0) //字符串对比是否是句号,如果是则换行
{
printf("\n");
}
}
cout << endl << endl;
char poetry[] = "一别都门三改火";
int j = 0;
while (j<strlen(poetry))
{
printf("%c%c", poetry[j], poetry[j + 1]);
j += 2;
Sleep(100);
}
cout << endl<< "---------------" << endl;
string po = "一别都门三改火";
int i = 0, len = po.length();
while (i<len)
{
printf("%c%c", po[i], po[i + 1]);
i += 2;
Sleep(100);
}
cout << endl;
//cout << sizeof(poetry) << endl;
//cout << strlen(poetry) << endl;
system("pause");
return 0;
}
cc++汉字的输出
最新推荐文章于 2023-11-15 13:00:57 发布