1 solutions
-
0
C++ :
#include<iostream> #include<string> using namespace std; int main(){ int n,cnt=0; cin>>n; string word; for (int i=1; i<=n; i++){ cin>>word; if (word[0]=='c' || word[0]=='C'){ cout<<word<<endl; cnt++; } } cout<<cnt<<endl; return 0; }Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int n=sc.nextInt(),count=0; for(int i=1;i<=n;i++){ String s=sc.next(); if(s.matches("\\b[cC].*\\b")){ System.out.println(s); count++; } } System.out.println(count); } sc.close(); } }
- 1
Information
- ID
- 18637
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By