/*Program to accept names of 5 students and display them in alphabetic order*/
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
int i=0,j=0;
char frame[5],temp[5];
clrscr();
for(i=0;i<4;i++)
{
printf("\nEnter student[%d]string",i);
scanf("%s",fname[1]);
}
for(i=0;i<=4;i++)
{
for(j=i+1;j<=4;j++)
{
if(strcmp(fname[i],fname[i])>0)
{
strcpy(temp,fname[i]);
strcpy(fname[i],fname[i]);
strcpy(fname[j],temp);
}
}
}
printf("The names of the students in alphabetic order is:");
for(i=0;i<=4;i++)
{
printf("\n%s",fname[i]);
}
getch();
}
#include
using std::cin;
using std::cout;
char names[5][256];
int main(int argc, char** argv)
{
for(int i = 0; i < 5; i++)
{
cout << "Enter Name #" << i + 1 << ": ";
cin.getline(names[i], 256);
}
cout << endl << endl;
for(int i = 0; i < 5; i++)
{
cout << "Name #" << i+1 << " = " << names[i] << endl;
}
}
There ya go,
Mrbiggbrain.
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using Actor = std::pair<std::string, std::string>;
using Actors = std::vector<Actor>;
struct comp {
bool operator()(const Actor& a, const Actor& b) {
return a.second<b.second ? true : !(b.second<a.second) ? a.first<b.first : false;
}
};
int main()
{
Actors actors = {{"John", "Wayne"}, {"Steve","McQueen"}, {"Bob","Hoskins"}, {"Bruce","Willis"}, {"Arnold","Schwarzenegger"}, {"Michael","Douglas"}, {"Kirk","Douglas"}};
std::cout << "Actors unsorted:\n" << std::endl;
for (size_t i=0; i<actors.size(); ++i)
std::cout << actors[i].first << ' ' << actors[i].second << std::endl;
std::cout << std::endl;
std::sort (actors.begin(), actors.end(), comp());
std::cout << "Actors sorted by surname:\n" << std::endl;
for (size_t i=0; i<actors.size(); ++i)
std::cout << actors[i].first << ' ' << actors[i].second << std::endl;
std::cout << std::endl;
}
Here is the c code:
#include
#include
void
swap(
char
str1[],
char
str2[]){
//helper function for swapping two strings
char
temp[50
];
strcpy(temp, str1);
strcpy(str1,str2);
strcpy(str2, temp);
}
void
sort( char
names[5
][50
] ){
int
i, j;
for
( i=
0
; i<
5
-
1
; i++){
//using bubble sort technique
for
( j=0
; j<5
-i-1
; j++){
if
( strcmp(names[j], names[j+1
]) > 0
)
swap(names[j], names[j+1
]);
}
}
}
int
main(){
char
names[5
][50
];
int
i;
printf(
"Enter the five names:\n");
for
( i=0
; i<5
; i++)
scanf("%49s"
, names[i]);
sort(names);
for
( i=0
; i<5
; i++)
printf("%s\t"
, names[i]);
printf("\n"
);
return
0
;
}
Well, we're not going to do it for you.There's some example code and tutorials at http://www.cplusplus.com/doc/tutorial/ . It's for C++, but the code is simple enough that it shouldn't make a difference. Adapt that, and it should do exactly what you want.
write a program which reads names of students and their telephones from a file and produce a linked list ordered in alphabetical order by the surname of the student.
An array is still an array, regardless of how you pass it into functions. It is still an array-type variable at the beginning of a function. However, the function itself may manipulate the array by "imploding" it into a string with a delimiter, using array values with only specific keys, and such.
In your main method: // Declare and initialize the array String names[] = {"Ana", "Bertha", "Cecilia", "Dora", "Emily"}; // Print backwards for (int i = names.length - 1; i >= 0; i--) System.out.println(names[i]); If you want to print the individual texts backwards (like "Dora" --> "aroD"), the StringBuffer class offers a method to do precisely that.
Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.
Well, we're not going to do it for you.There's some example code and tutorials at http://www.cplusplus.com/doc/tutorial/ . It's for C++, but the code is simple enough that it shouldn't make a difference. Adapt that, and it should do exactly what you want.
Program style refers to the way you write a program code. A good style is usually characterized by proper indentation, meaningful variable names, etc.
write a program which reads names of students and their telephones from a file and produce a linked list ordered in alphabetical order by the surname of the student.
There's several ways: 1) You can put square brackets on the end of a variable to create an array key inside that variable: $names['first'] = "john" $names['last'] = "smith" 2) You can use the array function: $names = array('first' => "john", 'last => "smith"); a lot of people set this function out like this: $names = array( 'first' => "john", 'last' => "smith" ); it makes it easier to read hope this helps
An array is still an array, regardless of how you pass it into functions. It is still an array-type variable at the beginning of a function. However, the function itself may manipulate the array by "imploding" it into a string with a delimiter, using array values with only specific keys, and such.
In your main method: // Declare and initialize the array String names[] = {"Ana", "Bertha", "Cecilia", "Dora", "Emily"}; // Print backwards for (int i = names.length - 1; i >= 0; i--) System.out.println(names[i]); If you want to print the individual texts backwards (like "Dora" --> "aroD"), the StringBuffer class offers a method to do precisely that.
There is no official translation, but there is an official system in Israel of transliterating Hebrew letters
Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.
#include<stdio.h> #include<string.h> #include<conio.h> void main() { int i; char a[10]; printf("enter ten names one by one"); for(i=0;i<=9;i++) { scanf("%s\n",a); } for(i=9;i<=0;i--) { printf("names are %s\n"); } getch(); }
Synthesia is a training program, not a composing or recording program. It was originally called 'Piano Hero', but had to change names under a threat of lawsuit from Activision.
int getNumMatches(String[] names) { int numMatches = 0; for(String name:names) { if(name.endsWith("ie") name.endsWith("y")) { ++numMatches; } } return numMatches; }
Write her name, age , place of the recital , what dance and to what music she performed, and the names of any students that accompanied her in the performance.