コード例 #1
0
int main() {
  int x,y,z, v;
    x=y=z=0;
#ifdef Q
    int qq = 30;
    cbar(qq);
#endif
#ifdef D
    int b=x;
    b = b*10;
#else
    int b=0;
    b = b * 20;
#endif
    if (x*y==3) {
        while (b) {
            y=y+2;
            z=z+x;
	    v = foo(z) * bar(z,y);
	    y = 3 * foo(2*x);
        }
    } else {
        x=x+3;
        x=x+1;
    }
#ifdef E1
  z = z *25000;
#ifndef E2
  b = b - 1000000;
#endif
#endif
    foo(4);
}
コード例 #2
0
ファイル: main.c プロジェクト: tiberig/aprsdump
int main(int argc, char *argv[])
{
	int rc, rdnum;
	printf("APRSDUMP V1.0, Stefan Koch <*****@*****.**>\n");

	if (2 != argc) {
		printf("need sound device\n");
		return EXIT_FAILURE;
	}
	audio_dev = strdup(argv[1]);
	//audio_dev = strdup("plughw:0,0");

	printf("- init audio capture\n");
	printf("  + audio device = %s\n", audio_dev);
	rc = audio_capture_init(audio_dev);
	if (0 == rc) {
		printf("  + init sucess\n");
	} else {
		printf("  + init failed (%d)\n", rc);
		return EXIT_FAILURE;
	}
	
	/* register sigint handler */
	printf("- register sigint handler\n");
	signal(SIGINT, sig_int_handler);

	/* start decoder loop */
	while (1 == run) {
		rdnum = audio_capture_read(&aubuf);
		if (-1 == rdnum) break;
	//	cdump(aubuf, rdnum);
		cbar(audiometer(aubuf, rdnum));
	}

	printf("- shutdown audio capture\n");
	audio_capture_close();

	return 0;
}
コード例 #3
0
ファイル: cvexample.cpp プロジェクト: kmanalo/advanced-cpp
int main()
{
    bar().foo();  // calls foo
    cbar().foo(); // calls foo const
}
コード例 #4
0
ファイル: Packing.cpp プロジェクト: Nomadluap/circles
void Packing::layout_hyperbolic(int centerCircle)
{
    qDebug() << "Performing hyperbolic layout...";
    QList<Node*> unplacedNodes(this->nodes); //Nodes which have not yet been placed
    QList<Node*> placedNodes; //nodes which have been placed but do not have full flowers.
    QList<Node*> floweredNodes; //nodes for which their entire flower has been placed.
    //place the first circle
    bool foundCenterCircle = false;
    for(Node* n: unplacedNodes){ //find the circle that is to be the center circle.
        if (n->getId() == centerCircle){
            qDebug() << "Placing first node #" << n->getId() << " at (0, 0)";
            n->setPosition(QPointF(0, 0));
            placedNodes.append(n);
            unplacedNodes.removeAll(n);
            //place the second node to right of the first node.
            Node *m = n->getNeibhours().first();

            if(!n->hasFullFlower()){
                int mindex = 1;
                do{
                    m = n->getNeibhours().at(mindex);
                    mindex++;
                } while(!m->hasFullFlower() && mindex < n->getNeibhours().length());

                if(mindex >= n->getNeibhours().length()){
                    qDebug() << "Neither M or N has full flower. Fail.";
                    return;
                }
            }
            qreal h1 = n->getRadius();
            qreal h2 = m->getRadius();
            //using the inverse of the log-formula
            //since the first point is at the origin we don't have to use an
            //isometry.
            qreal s = (exp(h1 + h2) - 1)/(exp(h1 + h2) + 1);
            m->setPosition(QPointF(s, 0));
            qDebug() << "Placing second node #" << m->getId() << " at (" <<
                        s << ", 0)";
            placedNodes.append(m);
            unplacedNodes.removeAll(m);
            foundCenterCircle = true;
            break;
        }
    }
    //fail if we didn't find the center circle
    if(!foundCenterCircle){
        qDebug() << "Could not find specified center circle. Fail.";
        return;
    }
    //now continue until all nodes have been placed...
    while(!unplacedNodes.empty()){
        bool nonFullOp = false;
        //find a placed node that does not have a full flower
        Node *w;
        int wIndex = 0;
        do{
            w = placedNodes.at(wIndex);
            wIndex++;
        } while(!w->hasFullFlower() && wIndex < placedNodes.length());
        //if w does not have a full flower at this point, then we need to get creative
        if(!w->hasFullFlower() && unplacedNodes.contains(w->getNeibhours().first())){
            nonFullOp = true;
        }
        //find a nbhr of w which has been placed.
        int nbhrIndex = 0;
        if(nonFullOp){
            nbhrIndex = w->getNeibhourCount() - 1;
            while(unplacedNodes.contains(w->getNeibhours().at(nbhrIndex))) nbhrIndex--;
        }
        else{
            //not an infinite loop since every placed node has at least one placed neibhour.
            while(unplacedNodes.contains(w->getNeibhours().at(nbhrIndex))) nbhrIndex++;
        }
        //now continue going around the nodes until we find the first one that is unplaced
        //we also need to check if the full flower has been placed.
        bool fullFlower = false;
        int nbhrOrigin = nbhrIndex;
        while(!unplacedNodes.contains(w->getNeibhours().at(nbhrIndex))){
            nbhrIndex = (nbhrIndex + 1) % w->getNeibhours().length();
            //if we wrap completely around, then we know that w's full flower
            //has been placed.
            if(nbhrIndex == nbhrOrigin){
                fullFlower = true;
                break;
            }
        }
        //if the full flower is complete, then update the lists and try again
        //with a different node.
        if(fullFlower){
            placedNodes.removeAll(w);
            floweredNodes.append(w);
            continue;
        }
        Node *u;
        if(nonFullOp){
            if(nbhrIndex == w->getNeibhourCount() - 1) u = w->getNeibhours().first();
            else u = w->getNeibhours().at(nbhrIndex+1);
        }
        else{
            if(nbhrIndex == 0) u = w->getNeibhours().last();
            else u = w->getNeibhours().at(nbhrIndex-1);
        }
        //now v becomes this "first unplaced node"
        Node *v = w->getNeibhours().at(nbhrIndex);
        if(!unplacedNodes.contains(v)){
        }
        //now we create a lambda phi which is an isometry
        QPointF wp = w->getPosition();
        auto phi = [wp](QPointF zz)->QPointF{
            std::complex<double> c(wp.x(), wp.y());
            std::complex<double> cbar(wp.x(), -wp.y());
            std::complex<double> z(zz.x(), zz.y());

            std::complex<double> result = (z - c)/(1.0 - cbar*z);
            return QPointF(result.real(), result.imag());
        };
        auto phiinv = [wp](QPointF zz)->QPointF{
            std::complex<double> c(wp.x(), wp.y());
            std::complex<double> cbar(wp.x(), -wp.y());
            std::complex<double> z(zz.x(), zz.y());

            std::complex<double> result = (z + c)/(1.0 + cbar*z);
            return QPointF(result.real(), result.imag());
        };
        //find the angle <UWV=alpha
        qreal alpha = this->angle(w, u, v);
        QPointF relU = phi(u->getPosition());
        qreal beta = atan2(relU.y(), relU.x());

        //we need to determine if the nodes are currently being laid out in a
        //clockwise or anticlockwise manner. Thus we need to look at the two
        //previous unplaced nodes, and look at their relative angles.

        //this only works if w has two or more placed neibhours so far.
        int placedCount = 0;
        int isCCW = true;
        for(Node *n: placedNodes + floweredNodes){
            if(w->isNeibhour(n)) placedCount++;
        }
        if(placedCount >= 2 && w->getNeibhours().length() >= 3){
            //grab uprime
            Node *uprime;
            if(nonFullOp){
                if(nbhrIndex == w->getNeibhourCount() - 1){
                    uprime = w->getNeibhours().at(1);
                }
                else if(nbhrIndex == w->getNeibhourCount() - 2){
                    uprime = w->getNeibhours().at(2);
                }
                else{
                    uprime = w->getNeibhours().at(nbhrIndex + 2);
                }
            }
            else{
                if(nbhrIndex == 0){
                    uprime = w->getNeibhours().at(w->getNeibhours().length() - 2);
                }
                else if(nbhrIndex == 1){
                    uprime = w->getNeibhours().last();
                }
                else{
                    uprime = w->getNeibhours().at(nbhrIndex - 2);
                }
            }
            //now look at angles of uprime and u
            //QPointF relUPrime = uprime->getPosition() - w->getPosition();
            QPointF relUPrime = phi(uprime->getPosition());
            qreal betaprime = atan2(relUPrime.y(), relUPrime.x());
            //difference between angles should be less than PI radians
            qreal diff = fmod(betaprime - beta + 2*PI, 2*PI);
            if(diff < PI){
                //betaprime is "ahead" of beta, so we should continue clockwise
                isCCW = false;
            }
            else{
                //betaprime is "behind" beta, so continue anticlockwise
                isCCW = true;
            }
        }

        qreal arg;
        if(isCCW) arg = fmod(beta+alpha+2*PI, 2*PI);
        else arg = fmod(beta-alpha+2*PI, 2 * PI);
        //now we plot the position of v, assuming that w is at the origin.
        //find euclidean distance s such that the hyperbolic distance from 0 to
        //s is equal to the sum of the hyperbolic radii.
        qreal r = w->getRadius() + v->getRadius();
        qreal s = (exp(r) - 1.0)/(exp(r)+1.0);
        //now plot the point using sin and cosine
        QPointF pos(s*cos(arg), s*sin(arg));
        //this is teh position relative to w. Now for
        //set the position of v, remembering to take the isometry into account.
        QPointF position = phiinv(pos);
        //QPointF position = w->getPosition() + pos;
        v->setPosition(position);
        //and update the lists
        unplacedNodes.removeAll(v);
        placedNodes.append(v);
        //and then we continue
    }
    qDebug() << "Layout complete";
}