#include <stdio.h> #include <string.h> struct avi { char arr[50]; int k; }s1[10]; int main() { int a,i,j,count=0; char temp[10]; strcpy(temp,"Ronaldo"); a=10; for(i=0;i<a;i++) { scanf("%s %d ",s1[i].arr,&s1[i].k); } for(i=0;i<a;i++) { // printf("%s",s1[i].arr) ; if( strcmp(s1[i].arr,temp)==0) {count++;} } // printf("%d",count) ; if(count==0) { printf("Ronaldo not appears in the list"); } if(count==1) { printf("Ronaldo appears once in the list"); } if(count==2) { printf("Ronaldo appears twice in the list"); } if(count>2) { printf("Ronaldo appears more than twice in the list"); } return 0; }
Problem Description
A foot ball team contains 10 players .Find a player name Ronaldo appear more than twice or not in an unordered name list.
-
Test Case 1
Input (stdin)
Thomas 100 Imran 105 Sithik 108 Setan 160 Milton 140 Martin 100 Lal 191 Jai 105 Ayush 107 Aswathy 103
Expected Output
Ronaldo not appears in the list
-
Test Case 2
Input (stdin)
Thomas 100 Imran 105 Sithik 108 Setan 160 Milton 140 Martin 100 Ronaldo 191 Jai 105 Ayush 107 Aswathy 103
Expected Output
Ronaldo appears once in the list