Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Given a positive integer n, the integers a1, ., an. Find the number and the sum of the members of the sequence that are divisible by 3 and not divisible by 5.

Читайте также:
  1. A) Pronunciation drill. Pronounce the words, then look at the given map and fill in the table below.
  2. Access to private and protected members of the containing type
  3. After having studied grammar (The Noun. The Number)
  4. Answer the questions. Write the number of the paragraph where you found the answer.
  5. Appendix 2: Assessment form for project group members
  6. As has already been mentioned, the verb has the grammatical categories ofperson, number, tense, aspect, voice andmood.
  7. ASIATIC MEMBERS OF THE INDO-EUROPEAN FAMILY.

import java.util.Scanner;

import java.util.*;

import java.io.*;

public class Zd1 {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

int n; int kolp=0; int i=0; int[] c; int sum=0;

System.out.println("введите размерность n");

n = in.nextInt();

c = new int[n];

for(i = 0; i < n; i++) c[i] = in.nextInt();

for(i=0;i<n;i++){ if(c[i]%3==0 && c[i]%5!=0){

kolp=kolp+1;

sum=sum+c[i];}}

System.out.println("кол-во =" +kolp);

System.out.println("сумма эл-тов ="+sum);}}

11) Given a positive integer n, the symbols s1,..., sn. Calculate how many of these characters equal to + symbol.

#include <iostream.h>

#include <string.h>

void main(void) {

int i; int N=0,k=0; char *S=0; S= new char[N];

cout<<"vvedite razmer masiva"<<endl; cin>>N;

cout<<"vvedite znachenia"<<endl;

for (int i = 0; i<N; i++)

{cin>>S[i];}

for (i = 0; i < N; i++) { if ((S[i] == '+')) { k++; } }

cout<<"olichestvo + ="<<k<<endl; }

12) Given a positive integer n, the symbols s1,..., sn. Calculate how many of these characters equal to * symbol.

#include <iostream.h>

#include <string.h>

void main(void) {

int i; int N=0,k=0; char *S=0; S= new char[N];

cout<<"vvedite razmer masiva"<<endl;

cin>>N;

cout<<"vvedite znachenia"<<endl;

for (int i = 0; i<N; i++)

{cin>>S[i];}

for (i = 0; i < N; i++) {

if ((S[i] == '*')) {

k++;

} } cout<<"olichestvo + ="<<k<<endl;

cin>>i;}

 

 

15) Given a positive integer n, the symbols s1,..., sn. Remove from the sequence all the substrings which are equal to abcd.

#include <string>

#include <iostream>

using namespace std;

void main(){int n=0;cin>>n; string a;cin>>a;

if (a.length()>n)

cout<<"oshipka";

else{string b="abcd";

string c="";string::size_type nd;

while((nd=a.find(b))!=string::npos)

a.replace(nd, b.size(), c);

cout<<a<<endl;}system ("pause");}

 

17) Given a positive integer n, the symbols s1,..., sn. Determine the number of entries in this sequence of strings: abc and aba.

#include <iostream>

#include <string.h>

using namespace std;

void main(void) { int i; int N=0,k=0,k1=0;

cout<<"vvedite razmer masiva"<<endl;

cin>>N; char *s=0;

s= new char[N]; cout<<"vvedite znachenia"<<endl;

for (int i = 0; i<N; i++) {cin>>s[i];}

for(int j=0;j<=N-3; j++) { if (s[j]=='a' && s[j+1]=='b' && s[j+2]=='c') k++;

if (s[j]=='a' && s[j+1]=='b' && s[j+2]=='a') k1++;

}cout<<k<<endl; cout<<k1<<endl;}

 

 

\

18) Given real numbers a1,..., a10. Calculate: a1 + a22 + a33+…+a1010.

#include <iostream>

#include <math.h>

using namespace std;

void main()

{ float a[10],b=0;

for(int i=0;i<10;i++)

{cin>>a[i];}

for(int i=0;i<10;i++)

b+=pow(a[i],(i+1)); cout<<b;}

 


Дата добавления: 2015-11-16; просмотров: 96 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Given a positive integer n, the real numbers a1, ..., an. Determine the number of pairs of consecutive integer numbers in this sequence which have different signs.| Given real numbers x, y1, ..., y25. In this sequence find two members, the arithmetic mean of which is closest to x.

mybiblioteka.su - 2015-2024 год. (0.005 сек.)