Sort by

recency

|

358 Discussions

|

  • + 0 comments
    c# csharp
    
    static void PrintArray<T>(T[] value)
        {
      //Linq ArrayForEach
            Array.ForEach(value, rec => Console.WriteLine($"{rec}"));
      //or Normal ForEach, both is working in similar way
      // foreach(var rec in value)
      //Console.WriteLine($"{rec}"); 
          }
    
  • + 0 comments
    template <typename T>
    void printArray(const vector<T>& vec) {
        for (const T& element : vec) {
            cout << element << endl;
        }
    }
    
  • + 0 comments
    import java.io.*;
    import java.util.*;
    import java.util.regex.*;;
    
    public class Solution {
    
        public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          while(sc.hasNext()) {
            int t = Integer.parseInt(sc.next());
            if(sc.hasNext(Pattern.compile("[0-9]+"))) {
              Integer[] ints = new Integer[t];
              for (int i = 0; i < t; i++) {
                ints[i] = sc.nextInt();
              }
              printArray(ints);
            } else {
              String[] strs = new String[t];
              for (int i = 0; i < t; i++) {
                strs[i] = sc.next();
              }
              printArray(strs);
            }
          }
          
          sc.close();
        }
        
        
        public static <T> void printArray(T[] array) {
          for (T t : array) {
            System.out.println(t);
          }
        }
    }
    
  • + 0 comments
    • class print{
    • public:
    • void print1(int arr[],int n){
    • for(int i=0;i
    • cout<
    • }
    • }
    • void print2(string arr1[],int n){
    • for(int i=0;i
    • cout<
    • }
    • }
      • };
      • int main() {
    • print p;
    • int n1,n2;
    • cin>>n1;
    • int arr[n1];
    • for(int i=0;i
    • cin>>arr[i];
    • }
    • cin>>n2;
    • string arr1[n2];
    • for(int i=0;i
    • cin>>arr1[i];
    • }
    • p.print1(arr,n1); p.print2(arr1,n2); type this in c++20 /* Enter your code here. Read input from STDIN. Print output to STDOUT */
  • + 2 comments

    Why python is not available for this problem