📜  程序打印快乐洒红节

📅  最后修改于: 2021-05-31 16:31:52             🧑  作者: Mango

Holi节即将到来,对于所有编码爱好者来说,这不仅仅是一个假期,而且要学习如何才能祝愿我们的编码朋友和他们对编码的愿望感到惊讶。 HpY Holi🙂

C++
// CPP program to print Happy Holi
#include 
using namespace std;
  
int main()
{
    // Print first row
    // You can choose any char
    char ch = '@';
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 10 || 
           i == 11 || i == 14 || i == 15 || 
           i == 16 || i == 17 || i == 19 || 
           i == 20 || i == 21 || i == 22 || 
           i == 24 || i == 27)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print second row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 ||
           i == 12 || i == 14 || i == 17 ||
           i == 19 || i == 22 || i == 24 || 
           i == 27)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print third row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 5 || i == 6 ||
           i == 7 || i == 9 || i == 10 || 
           i == 11 || i == 12 || i == 14 || 
           i == 15 || i == 16 || i == 17 || 
           i == 19 || i == 20 || i == 21 || 
           i == 22 || i == 25 || i == 26)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print fourth row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 || 
           i == 12 || i == 14 || i == 19 || 
           i == 25 || i == 26)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print fifth row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 || i == 12 ||
           i == 14 || i == 19 || i == 25 || i == 26)
            cout << ch;
        else
            cout << " ";
    }
  
    // Happy is printed, now print
    // Holi row by row
    cout << endl;
    cout << endl;
    cout << endl;
  
    // Print first row
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 10 || i == 11 || 
           i == 14 || i == 19 || i == 20 || i == 21 || 
           i == 22)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print second row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 || i == 12 ||
           i == 14 || i == 20 || i == 21)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print third row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 5 || i == 6 || i == 7 ||
           i == 9 || i == 12 || i == 14 || i == 20 || 
           i == 21)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print fourth row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 9 || i == 12 || 
           i == 14 || i == 20 || i == 21)
            cout << ch;
        else
            cout << " ";
    }
  
    // Print fifth row
    cout << endl;
    for (int i = 1; i <= 34; i++) {
        if (i == 4 || i == 7 || i == 10 || i == 11 || 
           i == 14 || i == 15 || i == 16 || i == 17 || 
           i == 19 || i == 20 || i == 21 || i == 22)
            cout << ch;
        else
            cout << " ";
    }
}


Java
// Java program to print Happy Holi
import java.io.*;
  
class GFG 
{
      
    public static void main (String[] args) 
    {
        // Print first row
        // You can choose any char
        char ch = '@';
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || 
            i == 11 || i == 14 || i == 15 || 
            i == 16 || i == 17 || i == 19 || 
            i == 20 || i == 21 || i == 22 || 
            i == 24 || i == 27)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print second row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 ||
            i == 12 || i == 14 || i == 17 ||
            i == 19 || i == 22 || i == 24 || 
            i == 27)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print third row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 5 || i == 6 ||
            i == 7 || i == 9 || i == 10 || 
            i == 11 || i == 12 || i == 14 || 
            i == 15 || i == 16 || i == 17 || 
            i == 19 || i == 20 || i == 21 || 
            i == 22 || i == 25 || i == 26)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print fourth row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || 
            i == 12 || i == 14 || i == 19 || 
            i == 25 || i == 26)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // print fifth row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 ||
            i == 14 || i == 19 || i == 25 || i == 26)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Happy is printed, now print
        // Holi row by row
        System.out.println();
        System.out.println();
        System.out.println();
      
        // Print first row
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || i == 11 || 
            i == 14 || i == 19 || i == 20 || i == 21 || 
            i == 22)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print second row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 ||
            i == 14 || i == 20 || i == 21)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print third row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 5 || i == 6 || i == 7 ||
            i == 9 || i == 12 || i == 14 || i == 20 || 
            i == 21)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print fourth row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 || 
            i == 14 || i == 20 || i == 21)
                System.out.print(ch);
            else
                System.out.print(" ");
        }
      
        // Print fifth row
        System.out.println();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || i == 11 || 
            i == 14 || i == 15 || i == 16 || i == 17 || 
            i == 19 || i == 20 || i == 21 || i == 22)
                System.out.print(ch);
            else
                System.out.print (" ");
        }
      
      
          
          
    }
}
  
// This code is contributed by vt_m.


Python3
# Python3 program to print Happy Holi
  
# Print first row
# You can choose any char
ch = '@'
for i in range(1, 35): 
        if (i == 4 or i == 7 or i == 10 or
            i == 11 or i == 14 or i == 15 or
            i == 16 or i == 17 or i == 19 or
            i == 20 or i == 21 or i == 22 or
            i == 24 or i == 27):
            print(ch, end = "")
        else:
            print(end = " ")
print()
  
# Print second row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or
        i == 12 or i == 14 or i == 17 or
        i == 19 or i == 22 or i == 24 or i == 27):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print third row
for i in range(1, 35):
    if (i == 4 or i == 5 or i == 6 or
        i == 7 or i == 9 or i == 10 or
        i == 11 or i == 12 or i == 14 or
        i == 15 or i == 16 or i == 17 or
        i == 19 or i == 20 or i == 21 or
        i == 22 or i == 25 or i == 26):
        print(ch, end = "")
    else:
        print(end = " ") 
print()
  
# Print fourth row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or
        i == 12 or i == 14 or i == 19 or
        i == 25 or i == 26):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print fifth row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or
        i == 12 or i == 14 or i == 19 or
        i == 25 or i == 26):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Happy is printed, now print
# Holi row by row
print()
print()
  
# Print first row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 10 or 
        i == 11 or i == 14 or i == 19 or
        i == 20 or i == 21 or i == 22):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print second row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or 
        i == 12 or i == 14 or i == 20
        or i == 21):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print third row
for i in range(1, 35):
    if (i == 4 or i == 5 or i == 6 or
        i == 7 or i == 9 or i == 12 or
        i == 14 or i == 20 or i == 21):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print fourth row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 9 or
        i == 12 or i == 14 or i == 20
        or i == 21):
        print(ch, end = "")
    else:
        print(end = " ")
print() 
  
# Print fifth row
for i in range(1, 35):
    if (i == 4 or i == 7 or i == 10 or i == 11 or
        i == 14 or i == 15 or i == 16 or i == 17 or
        i == 19 or i == 20 or i == 21 or i == 22):
        print(ch, end = "")
    else:
        print(end = " ")
  
# This code is contributed by Azkia Anam.


C#
// C# program to print Happy Holi
using System;
  
class GFG 
{
      
    // Driver Code
    public static void Main (String[] args) 
    {
        // Print first row
        // You can choose any char
        char ch = '@';
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || 
            i == 11 || i == 14 || i == 15 || 
            i == 16 || i == 17 || i == 19 || 
            i == 20 || i == 21 || i == 22 || 
            i == 24 || i == 27)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print second row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 ||
            i == 12 || i == 14 || i == 17 ||
            i == 19 || i == 22 || i == 24 || 
            i == 27)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print third row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 5 || i == 6 ||
            i == 7 || i == 9 || i == 10 || 
            i == 11 || i == 12 || i == 14 || 
            i == 15 || i == 16 || i == 17 || 
            i == 19 || i == 20 || i == 21 || 
            i == 22 || i == 25 || i == 26)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print fourth row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || 
            i == 12 || i == 14 || i == 19 || 
            i == 25 || i == 26)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // print fifth row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 ||
            i == 14 || i == 19 || i == 25 || i == 26)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Happy is printed, now print
        // Holi row by row
        Console.WriteLine();
        Console.WriteLine();
        Console.WriteLine();
      
        // Print first row
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || i == 11 || 
            i == 14 || i == 19 || i == 20 || i == 21 || 
            i == 22)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print second row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 ||
            i == 14 || i == 20 || i == 21)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print third row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 5 || i == 6 || i == 7 ||
            i == 9 || i == 12 || i == 14 || i == 20 || 
            i == 21)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print fourth row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 9 || i == 12 || 
            i == 14 || i == 20 || i == 21)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
        // Print fifth row
        Console.WriteLine();
        for (int i = 1; i <= 34; i++) {
            if (i == 4 || i == 7 || i == 10 || i == 11 || 
            i == 14 || i == 15 || i == 16 || i == 17 || 
            i == 19 || i == 20 || i == 21 || i == 22)
                Console.Write(ch);
            else
                Console.Write(" ");
        }
      
      
          
          
    }
}
  
// This code is contributed by parashar....


PHP


输出:

@  @  @@  @@@@ @@@@ @  @       
   @  @ @  @ @  @ @  @ @  @       
   @@@@ @@@@ @@@@ @@@@  @@        
   @  @ @  @ @    @     @@        
   @  @ @  @ @    @     @@        


   @  @  @@  @    @@@@            
   @  @ @  @ @     @@             
   @@@@ @  @ @     @@             
   @  @ @  @ @     @@             
   @  @  @@  @@@@ @@@@            
想要从精选的最佳视频中学习并解决问题,请查看有关从基础到高级C++的C++基础课程以及有关语言和STL的C++ STL课程。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”