Форум программистов, компьютерный форум, киберфорум
C для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.71/7: Рейтинг темы: голосов - 7, средняя оценка - 4.71
0 / 0 / 0
Регистрация: 16.11.2012
Сообщений: 6
1

Переписать код с C++ и заменить cout cin

18.12.2012, 21:57. Показов 1423. Ответов 1
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <string.h>
#include<stdio.h>
using namespace std;
struct ATSInfo {
char data[10];
int kod;
char city[20];
long talkTime;
int tarif;
char cityTelNumber[20];
char abonentTelNumber[20];
};
int main() {
struct ATSInfo information[100];
int i, kolZvonkov = 0;
char vubrCity[20];
long totalTime = 0, time = 0;
double sum = 0;
int tarif = 0;
 
 
cout << "Vvedite kolichestvo zvonkov: ";
cin >> kolZvonkov;
 
for (int i = 0; i < kolZvonkov; i++) {
 
cout << "Data: "; 
cin >> information[i].data;
cout << "Kod: "; 
cin >> information[i].kod;
cout << "Gorod: "; 
cin >> information[i].city;
cout << "Vremj razgovora (sec): "; 
cin >> information[i].talkTime;
cout << "Tarif: "; 
cin >> information[i].tarif;
cout << "Nomer telefona v gorode: "; 
cin >> information[i].cityTelNumber;
cout << "Nomer telefona abonenta: "; 
cin >> information[i].abonentTelNumber;
cout << "************************************" << endl;
 
}
 
cout << "\nVvedite gorod, dlj kotorogo bydet proizveden raschet: ";
cin >> vubrCity;
 
 
for (i = 0; i < kolZvonkov; i++) {
if (!strcmp(vubrCity, information[i].city)) 
{
 
sum += information[i].talkTime / 60.0 * information[i].tarif;
totalTime += information[i].talkTime;
}
}
 
cout << "\nObshaj informacij o " << vubrCity << ":\n"<< endl;
cout << "Vremj razgovora: " << totalTime << " seconds" << endl;
cout << "Raschet: " << sum << endl;
return 0;
}
0
Лучшие ответы (1)
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
18.12.2012, 21:57
Ответы с готовыми решениями:

Заменить cout и cin на printf и scanf
#include &lt;iostream&gt; using namespace std; struct elem { int info; // данные elem *next;...

Заменить cout и cin на printf и scanf
#include&lt;stdio.h&gt; #include&lt;iostream&gt; #include &lt;conio.h&gt; #include &lt;cstdlib&gt; using namespace...

Как переписать cout и cin на printf
Помогите глупому новичку! Как переписать в данных кодах эти cout и cin на простые например на...

переписать кусок проги с cin/cout на printf/scanf
переписать кусок проги с cin/cout на printf/scanf очень срочно, заранее спасибо char snn; int...

1
72 / 72 / 29
Регистрация: 10.08.2012
Сообщений: 202
19.12.2012, 01:54 2
Лучший ответ Сообщение было отмечено Памирыч как решение

Решение

C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<stdio.h>
#include<conio.h>
#include <string.h>
struct ATSInfo {
char data[10];
int kod;
char city[20];
long talkTime;
int tarif;
char cityTelNumber[20];
char abonentTelNumber[20];
};
int main() 
{
struct ATSInfo information[100];
int i, kolZvonkov = 0;
char vubrCity[20];
long totalTime = 0, time = 0;
double sum = 0;
int tarif = 0;
 
 
printf("Vvedite kolichestvo zvonkov:");
scanf("%d",&kolZvonkov);
 
for (int i = 0; i < kolZvonkov; i++) {
 
printf("Data:"); 
scanf ("%d", &information[i].data);
printf("Kod:"); 
scanf("%d", &information[i].kod);
printf ("Gorod: "); 
scanf ("%d", &information[i].city);
printf ( "Vremj razgovora (sec): "); 
scanf ("%d",&information[i].talkTime);
printf( "Tarif: "); 
scanf("%d", &information[i].tarif);
printf( "Nomer telefona v gorode: "); 
scanf ("%d",&information[i].cityTelNumber);
printf( "Nomer telefona abonenta: "); 
scanf("%d", &information[i].abonentTelNumber);
printf( "************************************\n");
 
}
 
printf ( "\nVvedite gorod, dlj kotorogo bydet proizveden raschet: ");
scanf ("%d", &vubrCity);
 
 
for (i = 0; i < kolZvonkov; i++) {
if (!strcmp(vubrCity, information[i].city)) 
{
 
sum += information[i].talkTime / 60.0 * information[i].tarif;
totalTime += information[i].talkTime;
}
}
 
printf( "\nObshaj informacij o\n ", vubrCity);
printf ("Vremj razgovora: ", totalTime );
printf ( "Raschet: ",  sum);
return 0;
}
1
19.12.2012, 01:54
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
19.12.2012, 01:54
Помогаю со студенческими работами здесь

Заменить printf scanf на cout cin
#include&lt;iostream.h&gt; #include&lt;math.h&gt; #pragma argsused int main(int argc, char* argv) {int i;...

Заменить cin cout на printf scanf
Преподаватель не хочет принимать код по минимальному основанию системы счисления , из-за того, что...

Заменить cout и cin на scanf и printf
#include &lt;iostream&gt; #include &lt;conio.h&gt; using namespace std; int calculate(int d1, int d2,...

Cin и cout заменить на scanf и printf
Препод придрался к коду и требует, чтобы я cin и cout заменил на scanf и printf. Поможете? или хотя...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
2
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru