void sea(int a[], int n) { int e, op; cout<<"\nWhich element do you want to search for: "; cin>>e; cout<<"1. Sequential search for sorted list\n"; cout<<"2. Sequential search for unsorted list\n"; cout<<"3. Binary search for sorted list\n"; cout<<"4. Exit\n"; cout<<"Give your option: "; cin>>op; int pos = -1; switch(op) { case 1: pos = sss(a,n,e); break; case 2: pos = ssu(a,n,e); break; case 3: pos = bs(a,n,e); break; case 4: return; } if(pos > 0) cout<<"The element was found at position no "<<pos; else cout<<"Element was not found!!"; }
TranslationInterface::TranslationInterface(QObject *parent) : QObject(parent) , m_service(NULL) , m_serviceItem(NULL) , m_busy(false) , m_suppressRetranslate(false) , m_sourceLanguages(new LanguageListModel(this)) , m_targetLanguages(new LanguageListModel(this)) , m_sourceLanguage(NULL) , m_targetLanguage(NULL) , m_dict(new DictionaryModel(this)) #ifdef Q_OS_SAILFISH , m_settings(new QSettings("harbour-taot", "taot", this)) #else , m_settings(new QSettings(QCoreApplication::organizationName(), "taot", this)) # ifdef WITH_ANALYTICS , m_analytics(new QAmplitudeAnalytics(AMPLITUDE_API_KEY)) # endif #endif { #ifdef WITH_ANALYTICS # if defined(Q_OS_SAILFISH) QString path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); path.append(QDir::separator()).append("harbour-taot"); QDir dir(path); if (!dir.exists()) dir.mkpath("."); m_analytics.reset(new QAmplitudeAnalytics(AMPLITUDE_API_KEY, dir.filePath("QtInAppAnalytics.ini"))); // HACK: Get proper manufacturer and model values // TODO: Remove when QtSystemInfo is allowed in Harbour QAmplitudeAnalytics::DeviceInfo di = m_analytics->deviceInfo(); org::nemo::ssu ssu("org.nemo.ssu", "/org/nemo/ssu", QDBusConnection::systemBus()); di.manufacturer = ssu.displayName(0 /*Ssu::DeviceManufacturer*/); di.model = ssu.displayName(1 /*Ssu::DeviceModel*/); m_analytics->setDeviceInfo(di); # endif updatePersistentProperties(); m_privacyLevel = PrivacyLevel(m_settings->value("PrivacyLevel", UndefinedPrivacy).toInt()); if (m_privacyLevel != NoPrivacy) m_analytics->setPrivacyEnabled(true); if (m_settings->contains("AppInfo/CurrentVersion")) { const QString version = m_settings->value("AppInfo/CurrentVersion").toString(); if (version != QCoreApplication::applicationVersion()) { QVariantMap props; props.insert("Old Version", version); props.insert("New Version", QCoreApplication::applicationVersion()); m_analytics->trackEvent("Upgrade", props); m_settings->setValue("AppInfo/CurrentVersion", QCoreApplication::applicationVersion()); } } else { QVariantMap props; props.insert("Version", QCoreApplication::applicationVersion()); m_analytics->trackEvent("Installation", props); m_settings->setValue("AppInfo/CurrentVersion", QCoreApplication::applicationVersion()); } if (m_privacyLevel == NoPrivacy) { trackSessionStart(); } #endif setTranscription(new SourceTranslatedTextPair()); setTranslit(new SourceTranslatedTextPair()); QStringList list; list.insert(GoogleTranslateService, GoogleTranslate::displayName()); list.insert(MicrosoftTranslatorService, MicrosoftTranslator::displayName()); list.insert(YandexTranslateService, YandexTranslate::displayName()); list.insert(YandexDictionariesService, YandexDictionaries::displayName()); m_services = new TranslationServicesModel(list, this); createService(m_settings->value("SelectedService", 0).toUInt()); connect(this, SIGNAL(sourceLanguageChanged()), SLOT(retranslate())); connect(this, SIGNAL(targetLanguageChanged()), SLOT(retranslate())); connect(this, SIGNAL(sourceLanguageChanged()), SIGNAL(canSwapLanguagesChanged())); connect(this, SIGNAL(targetLanguageChanged()), SIGNAL(canSwapLanguagesChanged())); connect(this, SIGNAL(detectedLanguageChanged()), SIGNAL(canSwapLanguagesChanged())); connect(this, SIGNAL(error(QString)), SLOT(onError(QString))); #ifdef Q_OS_SYMBIAN connect(qApp, SIGNAL(visibilityChanged()), this, SIGNAL(appVisibilityChanged())); #endif #ifdef Q_OS_BLACKBERRY m_invoker = new bb::system::InvokeManager(); connect(m_invoker, SIGNAL(invoked(bb::system::InvokeRequest)), this, SLOT(onInvoked(bb::system::InvokeRequest))); #endif }