简体   繁体   English

如何使用cout打印字符串的选定部分

[英]How to use cout to print selected parts of a string

This was a question given to me by my friend who is taking computer programming in college. 这是我上大学的计算机编程朋友给我的一个问题。

Try to write another program using only cout statements to print the initial of your last name in large letters using only *. 尝试仅使用cout语句编写另一个程序,以仅使用*以大写字母显示姓氏的首字母。

cout <<” * “ << endl;
cout <<” * * “ << endl;
cout << 

they use of course though the conio i've never used before. 他们当然会用,尽管我从未使用过conio。

#include <iostream>
#include <conio.h>
using namespace std;

How would this be possible? 这怎么可能?

Yes: 是:

// Last name Astari  =>initial of your last name is "A"

std::cout <<  "   **   \n";
std::cout <<  "  *  *  \n";
std::cout <<  "  ****  \n";
std::cout <<  "  ****  \n";
std::cout <<  "  *  *  \n";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM