Monday, April 03, 2017

কম্পিউটার প্রোগ্রামিং বই সমস্যা - 3

Computer Programming Book

- Problem 03 


Problem link:

http://cpbook.subeen.com/2012/11/count-numbers.html

Solution:

#include<stdio.h>
#include<string.h>
int main()
{

    int T,i,L,j,k,m;
    char str[10000000];
    scanf("%d\n",&T);
    for(i=1;i<=T;i++)
    {
        gets(str);
        L=strlen(str);
        int n=1;
        for(j=0; j<L; j++)
        {
  k=j+1;
  if(str[j]==' '&&(str[k]=='-'||(str[k]>='0'&&str[k]<='9'))) n++;
        }
        printf("%d\n",n);
    }
    return 0;
}
//LANGUAGE:C

No comments:

Post a Comment