import java.util.*;
class ISCprac2009q01{
public static void main(String args[])
throws InputMismatchException{
Scanner scan=new Scanner(System.in);
System.out.println("ENTER DAY NUMER(>=1 AND
<=366) : ");
int day_number=scan.nextInt();
System.out.println("ENTER YEAR(4 DIGIT) : ");
int year=scan.nextInt();
System.out.println("ENTER DATE AFTER(N)(>=1 AND
<=100) : ");
int n=scan.nextInt();
if(day_number<1 || day_number>366)
System.out.println("INVALID DAY NUMBER.");
else if(year<1000 || year >9999)
System.out.println("INVALID YEAR");
else if(n<1 || n>100)
System.out.println("INVALID DATE AFTER VALUE.");
else{
//INITIALIZE MONTH NAMES AND NUMBER OF DAYS IN EACH MONTH
String month_names[]={"JANUARY", "FEBRUARY","MARCH",
"APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER",
"OCTOBER","NOVERMBER","DECEMBER"};
int month_days[]={31,28,31,30,31,30,31,31,30,31,30,31};
int i, day, month,day_after;
String suffix;
//IF IT IS A LEAP YEAR FEBRURAY SHOULD HAVE 29 DAYS
if(year%400==0 || (year%100!=0 && year%4==0))
month_days[1]=29;
i=0;
//FIND THE DATE CORRESPONDING TO THE DAY NUMBER
day=day_number;
while(day>month_days[i])
{
day-=month_days[i];
i++;
}
month=i;
//ADD SUFFIX AS PER THE DAY
if(day%10==1 && day/10!=1)
suffix="ST";
else if(day%10==2 && day/10!=1)
suffix="ND";
else if(day%10==3 && day/10!=1)
suffix="RD";
else
suffix="TH";
System.out.println("OUTPUT:");
//FIRST PART OF THE OUTPUT
System.out.println(day+suffix+" "+
month_names[month]+" "+year);
//TO CALCULATE DATE AFTER N DAYS
day_after=day_number+n;
i=0;
while(day_after>month_days[i])
{
day_after-=month_days[i];
i++;
if(i==12){
i=0;
year++;
if(year%400==0 || (year%100!=0 && year%4==0))
month_days[1]=29;
}
}
day=day_after;
month=i;
//ADD SUFFIX AS PER THE DAY
if(day%10==1 && day/10!=1)
suffix="ST";
else if(day%10==2 && day/10!=1)
suffix="ND";
else if(day%10==3 && day/10!=1)
suffix="RD";
else
suffix="TH";
//SECOND PART OF THE OUTPUT
System.out.println(day+suffix+" "+
month_names[month]+" "+year);
}
}
}
没有import UIKit
import Parse
class FeedTableViewController: UITableViewController {
var usersBeingFollowed = [String]()
var imageFiles = [PFFile]()
var imageComment = [""]
var usernames = [String]()
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.hidesBackButton = true
let getFollowedUsersQuery = PFQuery(className: "Followers")
getFollowedUsersQuery.whereKey("follower", equalTo: PFUser.currentUser()!.objectId!)
getFollowedUsersQuery.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
self.usernames.removeAll(keepCapacity: true)
self.imageComment.removeAll(keepCapacity: true)
self.imageFiles.removeAll(keepCapacity: true)
self.usersBeingFollowed.removeAll(keepCapacity: true)
if let objects = objects {
for object in objects {
let followedUser = object["following"] as! String
let getFollowedUsers = PFQuery(className: "Post")
getFollowedUsers.whereKey("userId", equalTo: followedUser)
let getCurrentUser = PFQuery(className: "Post")
getCurrentUser.whereKey("userId", equalTo: (PFUser.currentUser()?.objectId)!)
var query = PFQuery.orQueryWithSubqueries([getFollowedUsers,getCurrentUser])
query.findObjectsInBackgroundWithBlock({ (imageObjects, error) -> Void in
if let objects = imageObjects {
for images in objects {
let userQuery = PFUser.query()
userQuery?.whereKey("_id", equalTo: images["userId"])
userQuery?.findObjectsInBackgroundWithBlock({ (user, error) -> Void in
print(user)
if let user = user {
for username in user {
self.usernames.append(username["username"] as! String)
}
}
})
self.imageFiles.append(images["imageFile"] as! PFFile)
self.imageComment.append(images["imageComment"] as! String)
self.tableView.reloadData()
}
}
})
}
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return usernames.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let myCell = tableView.dequeueReusableCellWithIdentifier("imagePostCell", forIndexPath: indexPath) as! cell
if imageFiles.count > 0{
myCell.userLabel.text = "\(usernames[indexPath.row]) completed the \(imageComment[indexPath.row]) challenge!"
imageFiles[indexPath.row].getDataInBackgroundWithBlock({ (data, error) -> Void in
if let downloadedImage = UIImage(data: data!) {
myCell.imagePost.image = downloadedImage
// self.tableView.reloadData()
}
})
}
return myCell
}
目录。如何使用此命令?