Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  SS.C
Language: C/C++
Code:
#include<stdio.h>
int main()
{
    int n,c,it,p[1000],i,j;
     scanf("%d",&n);
    printf("no.of test cases=%d\n",n);
     for(i=1;i<=n;i++)
     {
          scanf("%d \n %d \n ",&c,&it);
        printf("credit c=%d\n",c);
        printf("items it=%d\n",it);
          for(j=0;j<it;j++)
        {
            scanf("%d",&p[j]);
        }
        printf("prices of items in test case %d are:",i);
        for(j=0;j<it;j++)
        {
            printf(" %d\t",p[j]);
        }
        printf("\n");
        printf("case # %d :",i);
        for(i=1;i<=it;i++)
        {
            for(j=0;j<i;j++)
             {
                   if(p[i]+p[j]==c)
                         printf("%d %d\n",j+1,i+1);
                  
              }
         }
     }
     return 0;
}
          
Comments: