Esempio n. 1
0
void main()
{
   a[1]=new Node(76,96);
   a[2]=new Node(107,95);
   a[3]=new Node(97,88);
   b[1]=new Node(87,105);
   b[2]=new Node(112,107);
   b[3]=new Node(107,99); 
   Node *p;
   int i,j;

   int x1=a[1]->x;
   int y1=a[1]->y;
   int x2=a[2]->x;
   int y2=a[2]->y;
   int x3=a[3]->x;
   int y3=a[3]->y;

   for(j=88;j<=96;j++)
   {
	   for(i=76;i<=107;i++)
	   {
		   if(((((y1-y2)*(i-x2)+(x1-x2)*(y2-j))*((y1-y2)*(x3-x2)+(x1-x2)*(y2-y3)))>=0)&&((((y1-y3)*(i-x3)+(x1-x3)*(y3-j))*((y1-y3)*(x2-x3)+(x1-x3)*(y3-y2)))>=0)&&((((y3-y2)*(i-x2)+(x3-x2)*(y2-j))*((y3-y2)*(x1-x2)+(x3-x2)*(y2-y1)))>=0))
		  {
        p=san(1,2,3,i,j);
        cout<<"p("<<i<<","<<j<<")=("<<p->x<<","<<p->y<<")"<<endl;
		   }
	   }
   }
   
}
Esempio n. 2
0
File: 44.c Progetto: zyouyowa/pro2-c
int main(int argc, char const *argv[])
{
	printf("\x1b[2J");
	color(34);
	san(5,1);
	color(33);
	hei(30,1);
	color(0);
	printf("\n");
	return 0;
}
int main()
{
    int num,i,f;
    scanf("%d",&num);
    for(i=0;i<num;i++)
    {
        scanf("%d",&n);
        for(f=0;f<n;f++)
        {
            scanf("%lf%lf",&x[f],&w[f]);
        }
        printf("Case #%d: %.0lf\n",i+1,san());
    }
    return 0;
}
Esempio n. 4
0
int cal(int n,bool a[])
{
    san(n,a);
    int dem=0;
    for(int i=2;i<=n;i++)
    {
        if(a[i]==true)
        {
            int count = 0;
            int k=i;              
            while(k<=n)
            {
                count+=n/k;
                k*=i;           
            }
            dem++;
            if(dem==16) printf("\n%9d",count); 
            else printf("%3d",count);  
        }
    }
}
int check()
{
    if(1 == yi() || 1 == er() || 1 == san())
        return 1;
    return 0;
}
Esempio n. 6
0
    void Read(CObjectIStream* obj_in_stream,
              TCallback callback,
              const string& top_level_asn_object = kEmptyStr)
    {
        while ( !obj_in_stream->EndOfData() ) {
            // determine the ASN.1 object type
            string obj = obj_in_stream->ReadFileHeader();
            if ( obj.empty() ) {
                // auto-detection is not possible in ASN.1 binary mode
                // hopefully top_level_asn_object was specified by the user
                if ( top_level_asn_object.empty() ) {
                    NCBI_THROW(CException, eUnknown,
                        "ReadFileHeader() returned empty.  "
                        "Binary ASN.1 file?  "
                        "Please supply the top_level_asn_object.");
                }
                else {
                    obj = top_level_asn_object;
                }
            }
            else {
                if (!top_level_asn_object.empty()  &&  obj != top_level_asn_object) {
                    // object differs from the specified, skip it
                    continue;
                }
            }

            CTypesIterator i;
            CType<CSeq_align>::AddTo(i);

            if (obj == "Seq-entry") {
                CRef<CSeq_entry> se(new CSeq_entry);
                obj_in_stream->Read(Begin(*se), CObjectIStream::eNoFileHeader);
                if ( m_Scope ) {
                    m_Scope->AddTopLevelSeqEntry(*se);
                }
                for (i = Begin(*se); i; ++i) {
                    if ( CType<CSeq_align>::Match(i) ) {
                        callback(CType<CSeq_align>::Get(i));
                    }
                }
            }
            else if (obj == "Seq-submit") {
                CRef<CSeq_submit> ss(new CSeq_submit);
                obj_in_stream->Read(Begin(*ss), CObjectIStream::eNoFileHeader);
                CType<CSeq_entry>::AddTo(i);
                int tse_cnt = 0;
                for (i = Begin(*ss); i; ++i) {
                    if ( CType<CSeq_align>::Match(i) ) {
                        callback(CType<CSeq_align>::Get(i));
                    }
                    else if ( CType<CSeq_entry>::Match(i) ) {
                        if ( !(tse_cnt++) ) {
                            //m_Scope.AddTopLevelSeqEntry
                            (*(CType<CSeq_entry>::Get(i)));
                        }
                    }
                }
            }
            else if (obj == "Seq-align") {
                CRef<CSeq_align> sa(new CSeq_align);
                obj_in_stream->Read(Begin(*sa), CObjectIStream::eNoFileHeader);
                for (i = Begin(*sa); i; ++i) {
                    if ( CType<CSeq_align>::Match(i) ) {
                        callback(CType<CSeq_align>::Get(i));
                    }
                }
            }
            else if (obj == "Seq-align-set") {
                CRef<CSeq_align_set> sas(new CSeq_align_set);
                obj_in_stream->Read(Begin(*sas), CObjectIStream::eNoFileHeader);
                for (i = Begin(*sas); i; ++i) {
                    if ( CType<CSeq_align>::Match(i) ) {
                        callback(CType<CSeq_align>::Get(i));
                    }
                }
            }
            else if (obj == "Seq-annot") {
                CRef<CSeq_annot> san(new CSeq_annot);
                obj_in_stream->Read(Begin(*san), CObjectIStream::eNoFileHeader);
                for (i = Begin(*san); i; ++i) {
                    if ( CType<CSeq_align>::Match(i) ) {
                        callback(CType<CSeq_align>::Get(i));
                    }
                }
            }
            else if (obj == "Dense-seg") {
                CRef<CDense_seg> ds(new CDense_seg);
                obj_in_stream->Read(Begin(*ds), CObjectIStream::eNoFileHeader);
                CRef<CSeq_align> sa(new CSeq_align);
                sa->SetType(CSeq_align::eType_not_set);
                sa->SetSegs().SetDenseg(*ds);
                sa->SetDim(ds->GetDim());
                callback(sa);
            }
            else {
                if ( obj.empty() ) {
                    NCBI_THROW(CException, eUnknown,
                        "ReadFileHeader() returned empty.  "
                        "Binary ASN.1 file?  "
                        "Please supply the top_level_asn_object.");
                }
                else {
                    cerr << "Don't know how to extract alignments from: " << obj << endl;
                    cerr << "Do you know?  Please contact us at [email protected]." << endl;
                }
                return;
            }

            if (m_Verbose) {
                cerr << "Finished reading " << obj << "." << endl;
            }

        }            
    }