编程题:用*号输出字母C的图案
用 * 号输出字母 C! **** * * ****
int main() { int rows = 4; int cols = 4; for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { // 第一行和最后一行全输出星号 if (i == 0 || i == rows - 1) { printf("*"); } // 中间行只输出第一个星号 else if (j == 0) { printf("*"); } // 其他位置输出空格 else { printf(" "); } } printf("\n"); } return 0; }
#include <stdio.h> int main() { printf("****\n"); printf("*\n"); printf("*\n"); printf("****\n"); return 0; }
#include <stdio.h>
#include "stdlib.h"
#include "math.h"
int main(){
for(int i=0;i<4;i++){
for(int j=4;j>0;j--){
if(i==0) printf('#');
if(i==1){
printf('#');
continue;
}
if(i==2){
if(i==3) printf('#');
return 0;
1
#include<iostream>
using namespace std;
void manifest(int length)
{
if(length==0)
return;
cout<<"*";
manifest(length-1);
int main()
manifest(4);
cout<<endl;
manifest(1);
程序分析:可先用'*...
用户登录可进行刷题及查看答案
程序分析:可先用'*'号在纸上写出字母C,再分行输出
#include "stdio.h" int main() { printf("用 * 号输出字母 C!\n"); printf(" ****\n"); printf(" *\n"); printf(" * \n"); printf(" ****\n"); }
登录后提交答案